Tuesday, November 22, 2011

C and C++ Examples ( Multiple inheritance )


      /* PROGRAM TO IMPLEMENT MULTIPLE INHERITANCE */
#include<iostream.h>
#include<conio.h>
class lang
{
protected:
int tel,hin,eng;
public:
void getlang()
{
cout<<"enter tel,hin,eng marks:";
cin>>tel>>hin>>eng;
}
void putlang()
{
cout<<"the tel,hin,eng marks are:"<<tel<<endl<<hin<<endl<<eng<<endl;
}
};
class group
{
protected:
int math,phy,che;
public:
void getgroup()
{
cout<<"enter math,phy,che marks:\n";
cin>>math>>phy>>che;
}
void putgroup()
{
cout<<"the math,phy,che are";
cout<<math<<" "<<phy<<" "<<che<<" ";
}
};
class tot : public lang,public group
{
private:
int tot;
public:
void gettot()
{
tot=tel+hin+eng+math+phy+che;
}
void puttot()
{
cout<<"the total is"<<endl;
cout<<tot;
}
};
void main()
{
tot t;
t.getlang();
t.putlang();
t.getgroup();
t.putgroup();
t.gettot();
t.puttot();
getch();
}


OUTPUT :

enter tel,hin,eng marks: 74
96
86

enter math,phy,che marks:
77
98
85
 the total is:  516


0 comments:

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Vamshi krishnam raju | Bloggerized by Vamshi krishnam raju - Vamshi krishnam raju | Vamshi krishnam raju