Advertisement
powerofsoul

Untitled

Feb 28th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <string>
  7. using namespace std;
  8.  
  9. class test
  10. {
  11. public :
  12.     int x;
  13.  
  14.     test(const test &obj)
  15.     {
  16.         x = obj.x + 1;
  17.     }
  18.     test(int y)
  19.     {
  20.         x = y;
  21.     }
  22.     test& operator= (const test &obs)
  23.  
  24.     {
  25.         this->x = obs.x;
  26.         return *this;
  27.     }
  28. };
  29.  
  30. int main() {
  31.     test a(1);
  32.     test b(3);
  33.     b = a;
  34.     cout << b.x;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement