Skip to content

Instantly share code, notes, and snippets.

@Lowest0ne
Created November 10, 2013 01:15
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 Lowest0ne/7392346 to your computer and use it in GitHub Desktop.
Save Lowest0ne/7392346 to your computer and use it in GitHub Desktop.
delayed initialization in c++
#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