Sunday, June 1, 2014

Base class referring to an instance of a derived class

>>Is it possible for a Base class to refer to an instance of a derived class

No, this would defeat the purpose of inheritance. A Student is always a Person but a Person is not always a Student. The Person class doesn't know anything (and it shouldn't!) about the Student class nor any other class that might derive from it.

No comments:

Post a Comment