(iii) Write name of all data members accessible from member function of the class SoftToys.
Ans:
Toys::Price,
SoftToys::STName,
SoftToys::Weight
(iv) Write name of member functions accessible an object of the class ElectronicToys ?
Ans:
ElectronicToys::ETEntry( ),
Electronic Toys::ETDisplay( ),
Toys::TEntry( ),
Toys::TDisplay( )
DELHI 2007:
2.d) Answer the questions (i) to(iv) based on the following code:
4
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 ?
Ans: Multiple Inheritance. Since here the class Institute is deriving from the classes Learner and Trainer.
(ii) Identify the member function(s) that cannot be called directly from the objects of class Institute from the following
TEntry()
LDisplay()
IEntry()
Ans: All the above 3 member functions can be called directly from the objects of class Institute.
(iii) Write name of all member(s) accessible from member functions of class institute.
Ans:
Data Members – Trainer::Remuneration,
Learner::Attendance,
Learner::Grade,
Institute::ICode,
Institute::IName
Member functions – Trianer::AssignRem( ),
Trainer::TEntry( ),
Trainer::TDisplay( ),
Learner:: LEntry( ),
Learner::LDisplay( ),
Institute::IEntry ( )
(LDisplay can call IEntry( ))
Institute::LDisplay( )
(IEntry can call LDisplay( ))
(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.
Ans:
Institute::IEntry( ),
Institute:: IDisplay( )
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )