Skip to content

Instantly share code, notes, and snippets.

@eevee
Last active March 31, 2018 20:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save eevee/91006914b6b9aafa983bd8a9f6aedeb8 to your computer and use it in GitHub Desktop.
zero initialization in c++
#include <iostream>
#include <string.h>
struct A {
int b;
};
int main() {
{
char blah[256];
memset(blah, 0x1f, sizeof(blah));
}
{
A a1;
A a2{}; // most vexing parse
A a3 = A();
std::cout << a1.b << " " << a2.b << " " << a3.b << std::endl;
// output: 832 0 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment