1.

Predict the output of following C++ program?#include<iostream>using namespace std;class Test{private:int x;public:Test() {x = 0;}void destroy() { delete this; }void print() { cout << "x = " << x; }};int main(){Test obj;obj.destroy();obj.print();return 0;}(A) x = 0(B) undefined behavior(C) compiler error

Answer»


Discussion

No Comment Found

Related InterviewSolutions