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 static type of object? In standard, it doesn't say about dynamic type being dynamic object.
1.3.3 - The type of the most derived object (1.8) to which the lvalue denoted by an lvalue expression refers. [Example: if a pointer (8.3.1) p whose static type is "pointer to class B" is pointing to an object of class D, derived from B (clause 10), the dynamic type of the expression *p is "D." References (8.3.2) are treated similarly. ]
Also what does it the following quote mean
The dynamic type of an rvalue expression is its static type
class Base {
virtual void foo(){}
};
class Derived : public Base {
void foo(){}
};
int main()
{
Derived d;
Base *p = &d;
}