If a class x needs to be derived from a class y, which of the following ways is correct to do so?

Options
- class x : public y
- class y : public x
- class x derives public y
- class y derives public x


CORRECT ANSWER : class x : public y

Discussion Board
C++ - Inheritance

Inheritance provides an opportunity to reuse the code functionality and fast implementation time. The members of the class can be Public, Private or Protected. Syntax:class DerivedClass : AccessSpecifier BaseClass
The default access specifier is Private. Inheritance helps user to create a new class (derived class) from a existing class (base class).
Derived class inherits all the features from a Base class including additional feature of its own.

Prajakta Pandit 01-24-2017 06:17 AM

correct ans

Option b is correct

vignesh 07-3-2016 10:31 AM

ccc

nic

vinay chauhan 03-17-2015 12:29 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement