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
Who invented oop?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
Please send ford technologies placement paper 2 my mail id
Can we have inheritance without polymorphism?
What is an interface in oop?
how to get the oracle certification? send me the answer
Why is destructor used?
What does and I oop mean?
write a program that takes input in digits and display the result in words from 1 to 1000
How do you use inheritance in unity?
What do you mean by overloading?
can inline function declare in private part of class?
Get me a number puzzle game-program
write knight tour problem which is present in datastructure
Templates mean