May 2012
Intermediate to advanced
679 pages
16h 56m
English
Theoretically, pointers are pointers. There is no distinction, whether they point to a base class or to a derived class. In a highly disciplined language, these pointers belong to separate type. Pointer to base class is different from pointer to derived class. Just as pointer to int is distinct from pointer to float, pointer to Creature is distinct from pointer to Bird or Pet.
We can perform all normal operations on objects referred to using pointers. We have seen this in an earlier program. There pointer to class Bird was pointing to object of type Bird. There was no problem.
To support polymorphism in an elegant way, C++ makes a special deviation from its highly typed nature. It allows pointer to base ...
Read now
Unlock full access