Tuesday, 1 May 2012

Program Of Inheritance Using Constructor In C++

#include<iostream.h>
#include<conio.h>
class base
{
public:
base()
{
}
~base()
{
}
} ;

class derive : public base     // Single Inheritence
{

private:
int *a;
public:
derive()
{
cout<<"\n Derive CAlss Consructor";
a = new int [15];
}
~derive()
{
 cout<<"\n Derive CLass Destructor";
 delete []a;
}
} ;

main()
{
clrscr();
base  *ptr;
ptr = new derive;
delete ptr;
getch();
}

No comments:

Post a Comment