Advertisement
Guest User

VMWare's paste never works reliably. EVER. YOU PEOPLE DONT $

a guest
Dec 22nd, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class A{
  4. public:
  5. A( int n= 0 )
  6. : m_n( n )
  7. {
  8. std::cout << " init" << std::endl;
  9. }
  10. A( const A& a )
  11. : m_n( a.m_n )
  12. {
  13. std::cout << "copy" << std::endl;
  14. }
  15. private:
  16. int m_n;
  17. };
  18.  
  19. void f( const A &a1, const A &a2 = A() ){
  20. }
  21.  
  22. int main(){
  23. std::cout << "Line1" << std::endl;
  24. A a(2), b; //init init
  25. std::cout << "Line2" << std::endl;
  26. const A c(a), &d=c, e=b; //copy, copy, copy
  27. std::cout << "Line3" << std::endl;
  28. b =d; //copy
  29. std::cout << "Line4" << std::endl;
  30. A *p = new A(c), *q = &a; //init, init, copy
  31. std::cout << "Line5" << std::endl;
  32. static_cast<void>(q); //Que?
  33. std::cout << "Line6" << std::endl;
  34. delete p; //Nvmd.
  35. std::cout << "Line7" << std::endl;
  36. f(3); //meebe copy then copy?
  37. std::cout << "Line8" << std::endl;
  38. std::cout << std::endl;
  39. std::cout << "Line9" << std::endl;
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement