Guest User

Untitled

a guest
Feb 3rd, 2015
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. struct A
  4. {
  5.    int x;
  6.  
  7.    A()
  8.    {
  9.       std::cout << "Default constructor" << std::endl;
  10.       x = 0;
  11.    }
  12.  
  13.    A(const A& a)
  14.    {
  15.       std::cout << "Copy constructor" << std::endl;
  16.       x = a.x;
  17.    }
  18.  
  19.    A(const A&& a)
  20.    {
  21.       std::cout << "Move constructor" << std::endl;
  22.       x = a.x;
  23.    }
  24. };
  25.  
  26. A operator+(const A& a1, const A& a2)
  27. {
  28.     A temp;
  29.     temp.x = a1.x + a2.x;
  30.     return temp;
  31. }
  32.  
  33. int main()
  34. {
  35.     A a1, a2;
  36.     A s(a1 + a2);
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment