I'm reading Inside the C++ Object Model, and I'm somewhat confused as described below:
At the end of "1.2 A Keyword Distinction", the author pointed out that "This idiom is no longer recommended, however, because of changes to the class inheritance layout in some compilers":
PHP Code:
struct C_point { ... };
class Point : public C_point { ... };
extern void draw_line( Point, Point );
extern "C" void draw_rect ( C_point, C_Point );
draw_line( Point( 0, 0 ), Point( 100, 100 ));
draw_rect( Point( 0, 0 ), Point( 100, 100 ));
I guess the author meant that "some implementations began placing the vptr at the start of the class object... loss in C language interoperability" (from 3.4 Inheritance and the Data Member).
In my opinion, at the invocation of draw_rect(Point(0, 0), Point(100, 100)), the compiler knows draw_rect needs objects of type C_point, thus the compiler could push only the C_point part of the Point object into the stack. So I think the call to draw_rect with objects of type Point should be OK.
Would somebody please kindly tell me why and in what kind of situation will "draw_rect(Point(0, 0), Point(100, 100))" fail?