-->

Inheritance (Extending Classes)

Question
CBSEENCO12011719

Answer the questions (i) to (iv) based on the following:

class COMPANY
{
	char Location[20]; double Budget,Income;
protected:
	void Accounts( ); public:
	COMPANY();
	void Register( ); void Show( );
};
class FACTORY: public COMPANY
{
	char Location[20];
	int Workers;
protected:
	double Salary;
	void Computer();
public:
	FACTORY();
	void Enter( );
	void show( );
};
class SHOP: private COMPANY
{
	char Location[20];
	float Area;
	double Sale;
public:
	SHOP();
	void Input();
	void Output();
};

(i) Name the type of inheritance illustrated in the above C++ code.

(ii) Write the names of data members, which are accessible from member functions of class SHOP.

(iii) Write the names of all the member functions, which are accessible from objects belonging to class FACTORY.

(iv) Write the names of all the members, which are accessible from objects of class SHOP.

Solution
  1. Hierarchical Inheritance
  2. None of the data members can be accessible except SHOP class data
  3. Register( ),Enter( ) and Show( ) of Factory
  4. Input( ), Output( )

Some More Questions From Inheritance (Extending Classes) Chapter