Skip to content

Instantly share code, notes, and snippets.

@klmr
Created May 9, 2011 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klmr/963414 to your computer and use it in GitHub Desktop.
Save klmr/963414 to your computer and use it in GitHub Desktop.
Global non-POD in C++
#include <iostream>
struct nopod {
int x;
nopod() : x(42) { }
};
nopod foo;
int main() {
std::cout << foo.x << std::endl; // prints 42, NOT 0.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment