.
Home About-us Privacy Policy Contact-us Services

Thursday, October 8, 2015

C++ Program to concept of hybrid inheritance

ad+1

Program - 
 
#include<iostream.h>
#include<conio.h>
class abc
{
char name[20];
public:
void nput()
{
cout<<"enter the name==>";
cin>>name;
}
void rint()
{
cout<<"name is"<<name<<endl;
}
};
class sus:abc
{
int roll;
public:
void getdata()
{
abc::nput();
cout<<"enter the roll number==>";
cin>>roll;
}
void putdata()
{
abc::rint();
cout<<"roll number is"<<roll<<endl;
}
};
class as:abc
{
int marks;
public:
void input()
{
abc::nput();
cout<<"enter the marks==>";
cin>>marks;
}
void print()
{
abc::rint();
cout<<"marks obtained are"<<marks<<endl;
}
};
class address:public sus,as
{
char add[12];
public:
void ddata()
{
sus::getdata();
cout<<"enter the add";
cin>>add;
as::input();
}
void adata()
{
sus::putdata();
cout<<"add is"<<add<<endl;
as::print();
}
};
void main()
{
clrscr();
address m1;
m1.ddata();
m1.adata();
getch();
}

Output -

enter the name==>sushma
enter the roll number==>324
enter the add mukerian
enter the name==>sushma
enter the marks==>654

name is sushma
roll number is 324
add is mukerian
name is sushma
marks obtained are 654

 

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