Computer Science, asked by vermarahulkumar, 1 year ago

WAP to show the use of destructor .in 12th CMS practical.

Answers

Answered by KaranamSruthi
1
this is the way to show
Attachments:
Answered by pikuthakur12345
0

Answer:

#include <iostream>

using namespace std;

class HelloWorld{

public:

 //Constructor

 HelloWorld(){

   cout<<"Constructor is called"<<endl;

 }

 //Destructor

 ~HelloWorld(){

   cout<<"Destructor is called"<<endl;

  }

  //Member function

  void display(){

    cout<<"Hello World!"<<endl;

  }

};

int main(){

  //Object created

  HelloWorld obj;

  //Member function called

  obj.display();

  return 0;

}

Output:

Constructor is called

Hello World!

Destructor is called

Similar questions