Lippman大师(cfront实现者)的经典之作, 个人感触较深的部分有: virtual的实现(object的内存layout), exception的实现.
{test1}: c++ object model, constructor, destructor, and copy constructor/assignment operator.
object model when using multiple inheritence, expecially when using virtual member function or virtual inheritence
(adjustment of impliment this).
multiple inheritence and using virtual functions, the most derived class will have (N-1) virtual tables.
pointer to class data member (offset) and pointer to class member function (address or vtbl index).
{test2}:
1) template usage; scope of template declaration and scope of template instantiation.
template instantiation mechanism.
2) exception handling; catch block should use exception reference type, and if rethrow, a new copy will be delivered:
catch (A a) { ... throw; // the real parameter will be rethrowed (no matter with form parameter). }
3) RTTI: static_cast casts basetype* to derivedtype* in compile time, but may run into undefined state if infact it is not derivedtype*.
阅读(898) | 评论(0) | 转发(0) |