Inheritance Questions
Inheritance Questions
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 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();
};
(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.