Created
November 10, 2013 01:15
-
-
Save Lowest0ne/7392346 to your computer and use it in GitHub Desktop.
delayed initialization 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> | |
int doIt( void ) | |
{ | |
std::cout << "here\n"; | |
return 1234; | |
} | |
int size( void ) | |
{ | |
static int size = doIt(); | |
return size; | |
} | |
int main( void ) | |
{ | |
// uncomment to call | |
// std::cout << size() << '\n'; | |
// std::cout << size() << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment