Tuesday, 24 February 2015

Inheritenc Sample Program in C++

/*
Syntax For Inheritence
======================
class DerivedClassName:accessspecifier BaseClassName
{

}
*/
#include<iostream.h>
#include<conio.h>

class Base
{
public:
void BaseClass()
{
cout<<"\n I am Base Class";
}
};
class Derived:public Base
{
public:
void BaseClass()
{
cout<<"\n I am Derived Class";
}
};
main()
{
Derived d;
clrscr();
d.BaseClass();
d.Base::BaseClass();
getch();
}

No comments:

Post a Comment