.
Home About-us Privacy Policy Contact-us Services

Thursday, October 8, 2015

C++ Program to concept of hierarchical inheritance

ad+1

Program - 


#include<iostream.h>
#include<conio.h>
class abc
{
char name[20];
public:
void input()
{
cout<<"enter the name==>";
cin>>name;
}
void print()
{
cout<<"name is"<<name<<endl;
}
};
class sus:abc
{
int roll;
public:
void getdata()
{
abc::input();
cout<<"enter the roll number==>";
cin>>roll;
}
void putdata()
{
abc::print();
cout<<"roll number is"<<roll<<endl;
}
};
class as:abc
{
int marks;
public:
void input()
{
abc::input();
cout<<"enter the marks==>";
cin>>marks;
}
void print()
{
abc::print();
cout<<"marks obtained are"<<marks<<endl;

}
};
void main()
{
clrscr();
sus s1,s2;
as a1,a2;
cout<<"enter the data for student\n";
s1.getdata();
cout<<"enter the student marks\n";
a1.input();
cout<<"\n data of student\n";
s1.putdata();
cout<<"\n stu marks\n";
a1.print();
getch();
}

Output

enter the data for student
enter the name==>summi
enter the roll number==>5
enter the student marks
enter the name==>summi
enter the marks==>876

 data of student
name is summi
roll number is5

 stu marks
name is summi
marks obtained are876
 




0 comments:

Post a Comment

Home About-us Privacy Policy Contact-us Services
Copyright © 2014 All Programs Examples | All Rights Reserved. Blogger Templates Download Blogger Templates