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

Who invented oop?

857


Give an example where we have to specifically use C programming language and C++ programming language cannot be used?

1402


Please send ford technologies placement paper 2 my mail id

1861


Can we have inheritance without polymorphism?

817


What is an interface in oop?

790


how to get the oracle certification? send me the answer

1918


Why is destructor used?

774


What does and I oop mean?

858


write a program that takes input in digits and display the result in words from 1 to 1000

2204


How do you use inheritance in unity?

823


What do you mean by overloading?

818


can inline function declare in private part of class?

4008


Get me a number puzzle game-program

1950


write knight tour problem which is present in datastructure

2397


Templates mean

1858