COMPUTER SCIENCE INHERITANCE

(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] )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance2.php on line 162

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance2.php on line 162

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance2.php on line 164

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance2.php on line 164