Posted by Anonymous Wed 14th Mar 2007 15:51 - Syntax is C++ - 16 views
Download | New Post | Modify | Hide line numbers
  1. faux@molotov:~$ cat uhoh.cpp
  2. #include
  3.  
  4. int global=0;
  5.  
  6. class A
  7. {
  8. public:
  9.         A()
  10.         {
  11.                 std::cout << "COPEH " << ++global << std::endl;
  12.         }
  13.         ~A()
  14.         {
  15.                 std::cout << "die! " << global-- << std::endl;
  16.         }
  17.         void print()
  18.         {
  19.                 std::cout << "stuff" << std::endl;
  20.         }
  21. };
  22.  
  23. A foo()
  24. {
  25.         A local;
  26.         std::cout << "Inner foo" << std::endl;
  27.         return local;
  28. }
  29.  
  30. int main()
  31. {
  32.         A b = foo();
  33.         b.print();
  34. }
  35.  
  36. faux@molotov:~$ g++ -O0 uhoh.cpp && ./a.out
  37. COPEH 1
  38. Inner foo
  39. stuff
  40. die! 1
  41. faux@molotov:~$
  42.  

PermaLink to this entry https://pastebin.co.uk/11864
Posted by Anonymous Wed 14th Mar 2007 15:51 - Syntax is C++ - 16 views
Download | New Post | Modify | Hide line numbers

 

Comments: 0