A pointer is being printed because that is exactly what you are doing, for example:
Code:
int n = 5;
int *p = &n;
...
cout << p << endl; //prints the address of n
cout << *p << endl; //prints "5"
Your other problem is that you are trying to cast up inheritance that wasn't previously cast down, for example:
Code:
class base {};
class child : public base {};
...
child c;
base *pb = static_cast<base*>(&c); //cast down, ok
child *pc = static_cast<child*>(pb); //cast back up, ok since pb points to type child
...
base b;
pb = &b; //pb now points to type base
pc = static_cast<child*>(pb); //cast up, but pb currently points to type base - this is garbage, results undefined
Once you undestand that, what is wrong with this?
Code:
pointPtr = &p;
squarePtr = static_cast<Square *>(pointPtr); //cast up!!!!
gg