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
How is class defined?
What does and I oop mean in text?
which feature are not hold visual basic of oop?
What is the significance of classes in oop?
Plese get me a perfect C++ program for railway/airway reservation with all details.
How do you explain polymorphism?
What is destructor oops?
What are the types of abstraction?
Why do pointers exist?
What does and I oop and sksksk mean?
write a program that takes input in digits and display the result in words from 1 to 1000
What is oops with example?
What is oops?what is its use in software engineering?
What is debug class?what is trace class? What differences are between them? With examples.
What is the example of polymorphism?