fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool print(const char* msg)
  5. {
  6. cout << msg << endl;
  7.  
  8. return true;
  9. }
  10.  
  11. bool global = print("global");
  12. static bool static_global = print("static_global");
  13.  
  14. struct Foo{
  15. Foo(const char* msg) { print(msg); }
  16. void method(){
  17. bool local = print("local");
  18. static bool static_local = print("static_local");
  19. static Foo local_foo("local_foo");
  20. }
  21. };
  22.  
  23. static Foo foo("global_foo");
  24.  
  25. int main() {
  26. print("main begin >");
  27. foo.method();
  28. foo.method();
  29. print("< main end");
  30. return 0;
  31. }
Success #stdin #stdout 0s 4356KB
stdin
Standard input is empty
stdout
global
static_global
global_foo
main begin >
local
static_local
local_foo
local
< main end