What i think is that dynamic type means dynamically allocated object using new
. In the following case, do you say p
points to dynamic type or stati
What i think is that dynamic type means dynamically allocated object using new.
Nope.
The dynamic type is the real type of an object that might be accessed via a reference (pointer included) that point to a base type of its real type.
That is, if we have :
class A {
};
class B : public A { };
B l;
A& k = l;
Here k is a reference to an object of type A, but the real type of the referred object, its dynamic type, is B.
Here "dynamic" has the meaning of "known only at run-time".