If Child is inherited from Parent and overrides the function foo().
Child c;
Parent *p = &c;
p->foo();
How does the compiler know the type of the pointer p, since we are only passing the address of c with no other information?
Does the compiler automatically change the type of pointer p and behaves the same as the following?
Parent *p = new Child();
p->foo();