inside the cpp object model

1.多态只能用引用和指针, 重新解释了引用或指针指向的内存而已
2.类定义的完整性也包括vptr和vtbl
3.Type t=10,类似这种调用表示类Type有一个参数为整形的constructor
---------------------------------------------------------
1.类中定义的 copy constructor 和 operator = 都需要调用父类的同名函数
2.自定义操作符,需要给类的对象赋值的才有返回值
3.new 关键字 先分配存储空间后调用构造函数,如果有构造函数的话
#include <iostream>
using namespace std;
class a
{
public:
    inline a operator=(const a& ae);
    operator int()
    {
        return 0;
    }
};
inline a a::operator=(const a& ae)
{
    cout<<"i am operator"<<endl;
    return *this;
}
class b:public a
{
};
class c
{
public:
    c(int a=3,int b=4)
    {
        cout<<"i am c"<<endl;
    }
};
int main()
{
//    b bb,bc;
//
//    bb=bc;
    c cc[10];
    cout << "Hello world!" << endl;
    return 0;
}

 

posted on 2010-12-22 15:57  ATAK  阅读(184)  评论(0编辑  收藏  举报

导航