Predict the output of following program.

class ThisPointer {
private:
int x;
public:
ThisPointer()

{

x = 100;

}
void deletion()

{

delete this;

}
void display()

{

cout << "x = " << x; }
};
int main() {
ThisPointer tp;
tp.deletion();
tp.display();
return 0;
}

x=100
Compile time error
Undefined Behavior at run time like "Segmentation Fault" will be displayed in the console
x=0
Verified Answer
Correct Option - c

To get all Infosys Certified CPP Programmer Exam questions Join Telegram Group https://rebrand.ly/lex-telegram-236dee

Telegram