as

Write a C++ program to demonstrate Single Inheritances.

Write a C++ program to demonstrate Single Inheritances.    

Inheritance types


1. Single inheritance :-


Code :-
/**********program to implement inheritance(single inheritance)*****/
#include<iostream.h>
#include<conio.h>
class student
{
                int rno;
                char name[10];
                public:
                void get()
                {
                                cout<<"Enter The Roll No :- ";
                                cin>>rno;
                                cout<<"Enter The Name :- ";
                                cin>>name;
                }
                void put()
                {
                                cout<<"\nRoll No. is :- "<<rno;
                                cout<<"\nName is     :- "<<name;
                }
};
class course:public student
{
                char name [10];
                int fee;
                public:
                void input()
                {
                                cout<<"Enter Course Name :- ";
                                cin>>name;
                                cout<<"Enter Fee :- ";
                                cin>>fee;
                }
                void output()
                {
                                cout<<"\nCourse Name :- "<<name;
                                cout<<"\nCourse fee  :-  "<<fee;
                }
};
void main()
{              clrscr();
                course c;
                c.get();
                c.input();
                c.put();
                c.output();
                getch();
}
/*
Output :-
Enter The Roll No :- 12
Enter The Name :- Ram
Enter Course Name :- CPP
Enter Fee :- 2200
Roll No.  is      :- 12
Name is           :- Ram
Course Name  :- CPP
Course fee        :-  2200
*/
Output :-


Enter The Roll No :- 12
Enter The Name :- Ram
Enter Course Name :- CPP
Enter Fee :- 2200
Roll No.  is      :- 12
Name is           :- Ram
Course Name  :- CPP
Course fee        :-  2200