Code4Food
2022-6-1 11:00:26
In C, a pointer's actual address does not depend on its type. You can cast a pointer to another type and the address is unchanged. In C++, there are cases in which casting a class with multiple parent classes will changed the address. You need to understand class layout to see why.
C++'s pointer is also used for method lookup. The actually method may depend on the runtime type if a method is virtual. In C there is no such thing. Dereferencing a pointer using p->f just mean referencing the object at the address of p + a constant offset.
力=質量x加速度
2022-6-1 11:01:56
此回覆已被刪除
媽咪做社工
2022-6-1 11:03:15
So from C point of view
every C++ pointer is actually a fat pointer wrapping C pointer indicating its size of type
:^(
Ads
媽咪做社工
2022-6-1 11:04:42
No it seems that I misunderstand what you said
我都in過兩份