C++ Inheritance Question:
Download Job Interview Questions and Answers PDF
How to implement inheritance in C++?
Answer:
class Square: public Shape
{
...
};
In the above example all public members of Shape can be reused by the class Square. If public key word is left, private inheritance takes place by default. If protected is specified the inheritance is applied for any descendant or friend class.
{
...
};
In the above example all public members of Shape can be reused by the class Square. If public key word is left, private inheritance takes place by default. If protected is specified the inheritance is applied for any descendant or friend class.
Download C++ Inheritance Interview Questions And Answers
PDF
Previous Question | Next Question |
Explain the advantages of inheritance? | Do you know private inheritance? |