C++ program to demonstrate inheritance :
#include<iostream.h>
#include<conio.h>
class demo1 // base class
{
public :
void hello()
{
cout << "hello FROM DEMO1" <<endl;
}
};
class demo2 : public demo1 // derived class
{
public :
void hi()
{
cout << "hi FROM DEMO2" <<endl;
}
};
main()
{
clrscr();
demo2 d2;
d2.hello();
d2.hi();
getch();
}
Mar 26, 2007
Inheritance In C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment