Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class k
- {
- int i;
- public:
- k() : i(5) { cout << "Oops" << endl; }
- k(int a) : i(a) { cout << "I did" << i << endl; }
- k(const k& other) : i(other.i) { cout << "it" << i << endl; }
- ~k() { cout << "again" << endl; }
- int get() { return i; }
- void operator +=(const k&op) { i += op.i; }
- };
- void f(k& x, k y) {
- y += 1000;
- x += y;
- }
- int main() {
- k k1;
- k k2(30);
- k2 += 700;
- f(k1, k2);
- cout << k1.get() << " " << k2.get() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement