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 3 principles of oop?
What is the importance of oop?
What are the advantages of polymorphism?
Can a destructor be called directly?
2. Give the different notations for the class.\
What is an interface in oop?
What is debug class?what is trace class? What differences are between them? With examples.
Why is abstraction needed?
Can abstract class have normal methods?
Which type does string inherit from?
Can you inherit a private class?
Why interface is used?
What is abstraction in oop?
What is object-oriented programming? Webopedia definition
hi all..i want to know oops concepts clearly can any1 explain??