simplest hierarchical inheritance

Monday, October 19, 2015 Unknown 2 Comments


To create Simple hierarchical inheritance...




  • Definition:-
                    More than one class derived from single base class called hierarchical inheritance.

#include<iostream.h>
#include<conio.h>
class A
{
        public:
        void showA()
        {
                cout<<"It is class A";
        }
};
class B:public A        //class B derived from class A....
{
        public:
        void showB()
        {
                cout<<"It is class B";
        }
};
class C:public A       //class C Also derived from class A...
{
        public:
        void show C()
        {
                cout<<"It is class C";
        }
};
void main()
{
          C C1;
          C1.showA();
          C1.showB();
          C1.showC();
          getch();
}


OUTPUT:-
It is class A
It is class B
It is class C

To know about God and Godly University please click here : www.pbks.info

2 comments:

  1. Can you please upload the program file so I can use that directly?

    ReplyDelete
  2. If you direct download file and run that..
    So when we learn programming ??
    This program is uploaded to learn not for copy

    ReplyDelete