This article does not know what name to take, for the moment so called, directly to see the scene to understand. An excerpt from the Deep Exploration of C + + object model
Point3D origin, *pt = &origin;
(1) origin.x = 0;
(2) pt->x = 0
Both of these code execution results are the same, but are there any differences in execution efficiency?
(1) If Point3D is a normal struct, ordinary class, ordinary single inheritance or multiple inheritance, the execution efficiency of member X is exactly the same, because X's position in the class is offset and fixed at compile time (no virtual function is introduced). (2) If Point3D is virtual inherited from a base class, then PT cannot be determined at compile time to point to which class type, that is, cannot determine the offset position of x at compile time. Therefore, this access operation must be deferred to the executor, which can be resolved by an additional indirect boot, and the execution efficiency is slower than (1)
C + + Learning Path (10): implementation efficiency introduced by virtual inheritance