Originally Posted by
Mario F.
Gotcha!
I was thinking in terms of static memory.
Under this situation the dynamic type of the pointer is known at compile-time.
Didn't occur to me that quote was in the context of dynamic allocated memory.
even with static memory it can sometimes be impossible to know.
Code:
Base b;
Derived d; // assume d derived from b and overrides virtual func "DoStuff"
Base *pB = NULL;
char x;
cin >> x;
if (x == 'b')
pB = &b;
else if (x == 'd')
pB = &d;
if (pB)
pB->DoStuff();
All stack memory and still impossible to know at compile time.