Question:What will be the output of the following code?
class A
{
public:
      A():pData(0){}
      ~A(){}
      int operator ++()
      {
            pData++;
            cout << "In first ";
            return pData;
      }
      int operator ++(int)
      {
            pData++;
            cout << "In second ";
            return pData;
      }
private:
      int pData;
};

void main()
{
     A a;
     cout << a++;
     cout << ++a;
}
 

A In second 1 in first 2 

B In first 2 in first 1 

C In first 1 in first 2 

D In second 1 in first 1 

+ Answer
+ Report
Total Preview: 1065

Copyright © 2024. Powered by Intellect Software Ltd