一段时间没有写博客了,看了侯捷的《深入探索c++对象模型》,厚着脸皮写点安慰自己,因为这本书看起来真是有点吃力。
一,在C++中,有两种class data members:static和nonstatic,以及三种class member function:static、nonstatic和virtual。
如何模塑(modeling)出各种data members和function members呢?有三种模型
1,简单对象模型
2,表格驱动对象模型
3,c++对象模型
在这里就不详述了,点击打开链接说的很好。
二,C++程序设计模型直接支持三种programming paradigms(程序设计范式):
1,程序模型。字符串的处理就是一个例子
char boy[] = "Danny";
char *p_son;
...
p_son = new char [ strlen( boy ) + 1];
strcpy(p_son, boy);
...
if( !strcmp(p_son, boy))
take_to_disneyland(boy);
2,抽象数据类型模型(ADT)。例如下面的string class
String girl = "Anna";
String daughter;
...
//String::operator=();
daughter = girl;
...
//Srring::operator==();
if (girl == daughter)
take_to_disneyland(girl);
3,面向对象模型。Library_materials class就是一个例子
void
check_in(Library_materials *pmat)
{
if (pmat->late())
pmat->fine();
pmat->check_in;
if(Lender *plend = pmat->reserved())
pmat->notify(plend);
}