《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  a 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

转载于:https://www.cnblogs.com/dk647/archive/2011/04/13/2014181.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值