If the pointer is made and used in the derived class, it cannot be viewed in the base class. Consider the following simple outline:
- class Person {
-
// ... stuff here.
-
// for example,
-
public:
-
string name;
-
int age;
-
};
-
-
class Student : public person {
-
// ... stuff here.
-
// for example
-
public:
-
double GPA;
-
};
A Student object has a name, age, and GPA, but a Person object does not have a GPA, because a Person is NOT a Student. A Student IS-A Person, not vice versa.
Now, why do you need to use a derived class pointer in a base class? It would seem prudent to make this pointer in the base class so that both would have access to it.