Hierarchical Inheritance program in C++



Example:

Hierarchical Inheritance

#include<iostream.h>
#include<conio.h>
class account
               {
int id;
char name[20];
public:
void get();
void put();           
};
class saving : public account
               {
                              public:
void show();
               };
class current : public account
{
               Public:
void display();
};
void account :: get()
{
cout<<”Enter the Account Info = ”;
cin>>id>>name;    
}
void account :: put()
{
               cout<<” Account Info”;
               cout<<id<<name;
}
void saving :: show()
{
cout<<”Saving Account ”;
}
void current :: display()
{
               cout<<”Current Account”;
}
void main()
{
clrscr();
saving s;
current c;
s.get();
s.put();
s.show();
c.get();
c.put();
c.dispay();
getch();
}

No comments:

Post a Comment