Inside The C++ Object Model ---- Object Lessons
来源:互联网 发布:淘宝买家小号信誉查询 编辑:程序博客网 时间:2024/04/29 08:05
1. Layout Cost for Adding Encapsulation
inheritance don't have cost. But virtual function and virtual base class will add extra cost.
2. C++ Object Model
How Compiler implement the OO:
A Simple Object Model
A Table-driven Object Model
Two conceptions: virtual table vtbl;
vptr
How the Object Model Effects Programs
X foobar(){
X xx;
X *px = new X;
//foo() is virtual fucntion
xx.foo();
px->foo();
delete px;
return xx;
};
3. A Keyword Distinction
template <struct Type>
template <class Type>
struct mumble { ... };
4. An Object Distinction
C++ 直接支持三种programming paradigms (what's paradigm)
1.procedural model
2.abstract data type model
String girl = "Anna"
String daughter;
daughter = girl;
if (daughter == girl){
...
}
3.object-oriented model
void check_in(Library_materials *pmat){
if (pmat->late())
pmat->check_in();
if (Lender *plend = pmat->reserved())
pmat->notify( plend );
}
PROBLEM:
Book book;
thing1=book;
//book is sliced
think.check_in();
Library_materials &thing2 = book;
thing.check_in();
think1 = book 是ADT paradigm 的一种行为,用于OO就乱了
Although the polymorphic manipulation of an object requires that the object be accessed either through a
pointer or a reference, the manipulation of a pointer or reference in C++ does not in itself necessarily result
in polymorphism!
The C++ language supports polymorphism in the following ways:
1. Through a set of implicit conversions, such as the conversion of a derived class pointer to a pointer of
its public base type:
shape *ps = new circle();
2. Through the virtual function mechanism:
ps->rotate();
3. Through the dynamic_cast and typeid operators:
if ( circle *pc =
dynamic_cast< circle* >( ps )) ...
- Inside The C++ Object Model ---- Object Lessons
- Inside The C++ Object Model
- Inside the C++ Object Model
- 《Inside the C++ Object Model》
- Inside The C++ Object Model
- Inside The C++ Object Model
- Inside The C++ Object Model
- inside the c++ object model
- 读Inside the C++ Object Model有感
- Inside The C++ Object Model 笔记
- 《Inside the C++ Object Model》拿到了
- Inside The C++ Object Model (一)
- inside the c++ object model 读书笔记(第一章)
- 读书摘要--Inside The C++ Object Model
- Inside The c++ Object Model"勘误"
- Inside the C++ Object Model chapter 1
- 读书摘要--Inside The C++ Object Model
- Inside the C++ Object Model 笔记1
- getch()、getche()和getchar()之间的区别
- 三国战纪-风云再起----回忆当年心中的风云
- 第一次写Blog
- esr五部曲
- 驱动SYS开发总结
- Inside The C++ Object Model ---- Object Lessons
- 当SEA变成了BADA,让我们高呼女王万岁
- 为什么Marquee是不符合WEB标准的
- ~~
- ADSL装了路由器后如何上zone或者连IP打帝国
- 在这安家了
- php+apache配置Forbidden解决
- 纠正一下对 perl 的偏见
- ASP正则表达式详解 (一)