Suppose a class C inherits from a class B which overrides a virtual function defined in A. C does not override the function. When a pointer of type A* points to an object of type C, will the function call use the overridden version in B?
Yes!
Semantically, C
inherits its implementation from B
implicitly.
Concretely, the implementation of a virtual function that's called is the most derived available one.
When a pointer of type A* points to an object of type C, will the function call use the overridden version in B?
Yes.
是的函数调用将使用B中的重写版本,除非您在C中实现虚函数。在这种情况下,函数调用将是C.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.