MCQs > IT & Programming > C++ > 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; }

C++ MCQs

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;
}

Answer

Correct Answer: In second 1 In first 2

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it