Pointers in C++
A pointer is a variable whose value is the address of another variable.
Syntax:
Datatype *pointer-name;
Example:
int *p,a;
p=&a;
- Derived class pointer cannot point to base class.
|
|
The actual reason is - a derived class has all information about a base class and also some extra bit of information. Now a pointer to a derived class will require more space and that is not sufficient in base class. So the a pointer to a derived class cannot point to it. While on the other hand the reverse is true.
No comments:
Post a Comment