What is the output of the following snippet?

Last Updated on May 3, 2022 by Admin 2

What is the output of the following snippet?

#include <iostream>
using namespace std;

enum T { A = 2, B = -1, C };

class Int {
public:
    T v;
    Int(T a) { v = a; }
    Int & operator++() { v += 2; return *this; }
};

ostream &operator <<(ostream &o, Int &a) {
    ++a;
    return o << a.v;
}

int main()
{
   Int i = B;
    cout << i;
    return 0;
}
  • 0
  • 2
  • Compilation fails
  • 1
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments