T
Tony Johansson
Hello!!
I'm reading a book about C++ and there is something that I don't understand
so I ask you.
The book says
"The set of all public features of a class is called a public inteface, or
simply interface. When the inheritance hierarchy is
properly designed, the derived class interface conforms to the base class
interface. This leads to the substitutability principle:
Whenever the base class object is expected, you can use an object of a
derived class. For example, if an object of class BankAccount is expected,
you can instead use an object of the class CheckingAccount or of the class
SavingAccount.
You may violate the substitutability principle if you override a
nonpolymorphic operation"
Question 1.
What does they mean with this last line. "You may violate the
substitutability principle if you override a nonpolymorphic operation."
Question 2.What does they mean with "When the inheritance hierarchy is
properly designed, the derived class interface conforms to the base class
interface."
//Tony
I'm reading a book about C++ and there is something that I don't understand
so I ask you.
The book says
"The set of all public features of a class is called a public inteface, or
simply interface. When the inheritance hierarchy is
properly designed, the derived class interface conforms to the base class
interface. This leads to the substitutability principle:
Whenever the base class object is expected, you can use an object of a
derived class. For example, if an object of class BankAccount is expected,
you can instead use an object of the class CheckingAccount or of the class
SavingAccount.
You may violate the substitutability principle if you override a
nonpolymorphic operation"
Question 1.
What does they mean with this last line. "You may violate the
substitutability principle if you override a nonpolymorphic operation."
Question 2.What does they mean with "When the inheritance hierarchy is
properly designed, the derived class interface conforms to the base class
interface."
//Tony