Showing posts with label HYBRID INHERITANCE. Show all posts
Showing posts with label HYBRID INHERITANCE. Show all posts

Saturday, February 6, 2016

HYBRID INHERITANCE

AIM:
         To implement a C++ program to find out the student details and sport score using hybrid inheritance.
ALGORITHM:
Step 1: Include the header files
Step 2: Declare the base class stu.
Step 3: Declare and define the function get_ no () and put_no().
Step 4: Declare the derived class test for stu
Step 5: Declare and define the function get_ mark () and put_marks().
Step 6: Declare another base class sports
Step 7: Declare and define the function \getscore () and putscore ()
Step 8: Declare the derived class result from test and sports
Step 9: Declare and define the function display ()
Step 8: Create objects for the derived class.
Step 9: Declare the derived class object, call the functions get_ no ( ),get_ mark ( ),getsscore (),display ()

PROGRAM:

#include<iostream.h>
#include<conio.h>
class stu
{
protected:
  int rno;
public:
void get_no(int a)
{
rno=a;
}
void put_no(void)
{
cout<<"Roll no"<<rno<<"\n";
}
};
class test:public stu
{
protected:
float part1,part2;
public:
 void get_mark(float x,float y)
 {
part1=x;
part2=y;
 }
void put_marks()
{
cout<<"Marks obtained:"<<"part1="<<part1<<"\n"<<"part2="<<part2<<"\n";
}
};