Is it correct?
That's right, the type is inferred at compile time. auto uses the same rules for outputting a template argument to output a type based on a static type; dynamic polymorphism is not considered.
For this case, type d is equal to B* , then type *d is equal to B , therefore type B is equal to B Then *d will be adjusted with segments to B , for bf() B::f() should be called.
The code is equivalent to the following, which may be clearer.
B b = *d; bf();
songyuanyao
source share