113. Operator Overloading-I

Question.6

A developer overloads both prefix and postfix increment:

class Counter {
   int val;
public:
   Counter(int v) : val(v) {}
   Counter& operator++()     { val++; return *this; }  // Prefix
   Counter  operator++(int)  { Counter old = *this; val++; return old; } // Postfix
};

Counter c(5);
Counter a = ++c;
Counter b = c++;
printf("%d %d %d", a.val, b.val, c.val);

What is the output? (Assuming public access for printf.)

Need Help? Refer to the Quick Guide below

Select Answer