You are on the right track! You should use the "p" defined in the parent class. In the derived class setter methods you enforce that the derived type must be used (as the parameter type). For instance your constructor for defined will be:
derived(int _num, derived** _ps) : parent(_num, _ps){};
Then, when you're using p in the derived methods, you know that p is really a derived type, and you can safely cast it.