《inside the cpp object model》 阶段性阅读总结

本打算看完再总结的。。结果发现看完这本书需要的时间实在是太长了。
为了避免遗忘,于是决定进行阶段性总结。。。。
(为了练习英语,我会尽量用英语来表达。希望英语好的同学帮我指正)
for a c++ object model, we mainly consider two aspects:
  1. the one is language supporting for OO
  2. the other is mechanism supporting that how a compiler implemented it.
《inside the cpp object model》(we call it ITCOM in the remain article。。。)major in the mechanism supporting.
chapter 1  object lessons
this chapter mainly explains the differences between the global data with operating in c and the encapsulated object in c++
pre sections layout cost for adding encapsulation
some people think that the encapsulation in c++ have a big additional layout cost.after reading this chapter, we can say it's wrong.the primary cost is virtuals.
section 1 the c++ object model
this section mentions 3 kinds of object model. 
first ,a simple object model is a object which contents a sequence of slots pointing to a member.
second,a table-driven object model is a object which content two pointers point to member tables.one table content slots pointing to the function members, another content the data member directly."this model has been the traditional 
implementation supporting efficient runtime resolution of virtual functions"
third,the c++ object model is derived from the simple object.the nonstatic member directly stored in the object .static member stored in the class.function members hoisted outside the class(yes,nether directly nor indirectly stored in the class).when we use the virtual functions, vptr will stored in each object.
this section also discussed the inheritance adding,we have two means to do it.
first,we store a slot hold the address of base class suboject within the derived class object
second,we directly store the data member of the base class subobject with in the derived class object(yes, it's used in c++)
section 2 keyword distinction
this section mainly discuss the difference between struct and class in c++,the primary difference is not that struct is public and the class is private in default access.yes,we should consider the programming in two parts---coder and compiler.using struct or class is for coder to read code clearly not for compiler to run fast or more.
section 3 an object distinction
this section mainly talk about 3 programming paradigm in c++
we can use procedural model as programmed in c
we can use ADT(abstract data type) model , such as a string class
we can use the object-oriented model
here are the differences:
resolving actual type in runtime can be used only in OO not ADT or PRO.
polymorphism exists only within individual public class hierarchies
this section also tell us the memory requirement of a class object,derived sliced.
c++ support polymorphism through class pointers and references.this style of programming is called OO
c++ also supports aconcrete ADT style of programming now called object-based(OB)—nonpolymorphic data types, such as a String class
posted @ 2011-04-13 11:58  dk647  阅读(929)  评论(0编辑  收藏  举报