Advertisement
szaszm01

what does it print?

Jul 26th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. class A {
  4.     int k;
  5. public:
  6.     A(const int i = 0) :k(i) { cout << 'k'; }
  7.     A(const A& a) { k = a.k; cout << 'c'; }
  8.     void operator=(A &a) { k = a.k; f(a); cout << 'e'; }
  9.     A &operator*(int i) { cout << i*100; return *this; }
  10.     void f(A a) { k++; cout << 'f'; }
  11.     ~A() { cout << 'd'; }
  12. };
  13.  
  14. A &operator*(int i, A& a) { cout << i; return a; }
  15.  
  16. int main() {
  17.     A a = A(1); cout << '\n';
  18.     a = a * 2; cout << '\n';
  19.     a = 3 * a; cout << '\n';
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement