Sunday, 3 February 2019

Write a Program of Constructor and Destructor in c++

Program to implement the concept of  and destructor in C++



#include<iostream.h>
#include<conio.h>
 class A
 {  int x;
public :A()    //creating a constructor
{


cout<<"\n EXecution in constructor";

 }
 public: ~A()   //creating a destructor
{
cout<<"\n Execution in Destructor";
 }};
int main()
{clrscr();
A* obj=new A; //making an object will call constructor automatically
delete obj; //deleting object will call destructor automatically

getch();
return 0;}




OutPut screen will look like this:-


No comments:

Post a Comment

👇 🌐 Top 10 Hosting for Developers in 2025: Fast, Reliable & Affordable

 Whether you’re a beginner building your first portfolio site or a professional developer deploying client projects, choosing the right host...