Home » C++ Programming » Constructors and Destructors

What will be the output of the following program? #include class CuriousTab { int x, y; public: CuriousTab(int xx) { x = ++xx; } ~CuriousTab() { cout<< x - 1 << " "; } void Display() { cout<< --x + 1 << " "; } }; int main() { CuriousTab objCuriousTab(5); objCuriousTab.Display(); int *p = (int*) &objCuriousTab; *p = 40; objCuriousTab.Display(); return 0; }

← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!