.
Home About-us Privacy Policy Contact-us Services

Thursday, October 8, 2015

C++ Program to concept of multilevel 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<<"\n\n";
cout<<"name is"<<name<<endl;
}
};
class sus:abc
{
int roll;
public:
void getdata()
{
abc::input();
cout<<"enter the number==>";
cin>>roll;
}
void putdata()
{
abc::print();
cout<<"roll number is"<<roll<<endl;
}
};
class as:private sus
{
int marks;
public:
void input()
{
getdata();
cout<<"enter the marks==>";
cin>>marks;
}
void print()
{
putdata();
cout<<"marks obtained are"<<marks<<endl;
}
};
void main()
{
clrscr();
as a;
a.input();
a.print();
getch();
}

Output - 

enter the name==>balkar
enter the number==>12
enter the marks==>88

name is balkar
roll number is 12
marks obtained are 88

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