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 first 1 In second 2 

B In second 1 In first 2 

C In first 0 In second 2 

D In second 0 In first 2 

+ Answer
+ Report
Total Preview: 877

Copyright © 2024. Powered by Intellect Software Ltd