what is single inheritance?

Answer Posted / sabari

Deriving only one class from base class is called single inheritance.
For example:
#include<iostream.h>
#include<conio.h>
class student
{
public:
int rno;
char na[30];
void input();
};
void student::input()
{
cout<<"enter the student name";
cin>>na;
cout<<"enter the register no:";
cin>>rno;
}
class mark:public student //derivation
{
int m1,m2,m3;
float t,av;
public:
void display()
{
cout<<"Enter m1,m2,m3 values\n"
cin>>m1>>m2>>m3;
t=m1+m2+m3;
av=t/3;
cout<<endl<<"name="<<na;
cout<<endl<<"Register number="<<rno;
cout<<endl<<"total="<<t;
cout<<endl<<"average="<<av;
}
};
void main()
{
clrscr();
mark ob;
ob.input();
ob.display();
getch();
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of polymorphism?

573


What is overloading in oop?

572


What is an interface in oop?

591


when to use 'mutable' keyword and when to use 'const cast' in c++

1642


Why it is called runtime polymorphism?

573






What is encapsulation in oop?

601


What is object in oop?

677


What is abstraction in oops with example?

770


What is static in oop?

585


Is this job good for future? can do this job post grduate student?

1689


what type of questions

1695


What are classes oop?

596


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

1833


Why is polymorphism important in oop?

629


what's the basic's in dot net

1734