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

DBMS NOTES UNIT 3

                                                              UNIT 3  ER (Entity Relationship) An entity-relationship model is known as an E...