0% found this document useful (0 votes)
132 views3 pages

Inheritance Questions

This document contains code examples demonstrating inheritance in C++ and questions about the code. The code examples show classes derived from base classes using public inheritance. The questions ask about (i) the type of inheritance shown, (ii) data members and member functions accessible from the derived classes, and (iii) the impact of using private inheritance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views3 pages

Inheritance Questions

This document contains code examples demonstrating inheritance in C++ and questions about the code. The code examples show classes derived from base classes using public inheritance. The questions ask about (i) the type of inheritance shown, (ii) data members and member functions accessible from the derived classes, and (iii) the impact of using private inheritance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

COMPUTER SCIENCE INHERITANCE

2.d) Answer the questions (i) to(iv) based on the following code :
class Dolls public:
{ SoftDolls();
char Dcode[5]; void SDInput();
protected: void DShow();
float Price; };
void CalcPrice(float);
public: class ElectronicDolls:public Dolls
Dolls(); {
void DInput(); char EDName[20];
void DShow(); char BatteryType[10];
}; int Batteries;
public:
class SoftDolls:public Dolls ElecronicDolls();
{ void EDInput();
char SDName[20]; void EDShow();
float Weight; };
(i) Which type of Inheritance is shown in the above example?
(ii) How many bytes will be required by an object of the class ElectronicDolls ?
iii) Write name of all data members accessible from member function of the class SoftDolls.
(iv) Write name of member functions accessible an object of the class ElectronicDolls?

2.d) Answer the questions (i) to(iv) based on the following code :
class Toys public:
{ SoftToys();
char Tcode[5]; void STentry();
protected: void STDisplay();
float Price; };
void Assign(float);
public: class ElectronicToys:public Toys
Toys(); {
void Tentry(); char ETName[20];
void Tdisplay(); int No_of_Batteries;
}; public:
ElecronicToys();
class SoftToys:public Toys void ETEntry();
{ void ETDisplay();
char STName[20]; };
float Weight;
(i) Which type of Inheritance is shown in the above example?
(ii) How many bytes will be required by an object of the class SoftToys ?
(iii) Write name of all data members accessible from member function of the class SoftToys.
(iv) Write name of member functions accessible an object of the class ElectronicToys ?
2.d) Answer the questions (i) to(iv) based on the following code:

class Trainer
{
char TNo[5],Tname[20],specialization[10];
int Days;
protected :
float Remuneratoin;
void AssignRem(float);
public:
Trainer();
void TEntry();
void TDisplay();
};

class Learner
{
Char Regno[10],LName[20],Program[10];
protected:
int Attendance,grade;
public:
Learner();
void LEntry();
void LDisplay();
};

Class Institute:public Learner,public Trainer


{
char ICode[10],IName[20];
public:
Institute();
void IEntry();
void IDisplay();
};

(i) Which type of inheritance is depicted by above example ?


(ii) Identify the member function(s) that cannot be called directly from the objects of class
(iii) Write name of all member(s) accessible from member functions of class institute.
(iv) If class institute was derived privately from class Learner and privately from class Trainer, then name
the member function(s)that could be accessed through Objects of class Institute.

2.d) Answer the questions (i) to(iv) based on the following code:

class Teacher
{
char TNo[5],Tname[20],Dept[10];
int Workload;
protected :
float Salary;
void AssignSal(float);
public:
Teacher();
void TEntry();
void TDisplay();
};
class Student
{
char
Admno[10],SName[20],Stream[10];
protected:
int Attendance,Totmarks;
public:
Student();
void SEntry();
void SDisplay();
};
class School:public Student,public Teacher
{
char SCode[10],SName[20];
public:
School( );
void SchEntry();
void SchDisplay();
};

(i) Which type of inheritance is depicted by above example?

(ii) Identify the member function(s) that cannot be called directly from the objects of class School
from the following

(iii) Write name of all member(s) accessible from member functions of class School.

(iv) If class School was derived privately from class Learner and privately from class Trainer,then
name the member function(s)that could be accessed through Objects of class School.

You might also like