Created
May 9, 2011 21:07
-
-
Save klmr/963414 to your computer and use it in GitHub Desktop.
Global non-POD in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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