Advertisement
HellFinger

Untitled

Oct 31st, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class k
  6. {
  7.     int i;
  8. public:
  9.     k() : i(5) { cout << "Oops" << endl; }
  10.     k(int a) : i(a) { cout << "I did" << i << endl; }
  11.     k(const k& other) : i(other.i) { cout << "it" << i << endl; }
  12.     ~k() { cout << "again" << endl; }
  13.     int get() { return i; }
  14.     void operator +=(const k&op) { i += op.i; }
  15. };
  16.  
  17. void f(k& x, k y) {
  18.     y += 1000;
  19.     x += y;
  20. }
  21.  
  22. int main() {
  23.  
  24.   k k1;
  25.   k k2(30);
  26.   k2 += 700;
  27.   f(k1, k2);
  28.   cout << k1.get() << " " << k2.get() << endl;
  29.   return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement