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
What are the advantages of polymorphism?
What is overloading in oop?
What is an interface in oop?
when to use 'mutable' keyword and when to use 'const cast' in c++
Why it is called runtime polymorphism?
What is encapsulation in oop?
What is object in oop?
What is abstraction in oops with example?
What is static in oop?
Is this job good for future? can do this job post grduate student?
what type of questions
What are classes oop?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
Why is polymorphism important in oop?
what's the basic's in dot net