2013年2月18日

static成员函数、成员变量

摘要: class Cat{public: Cat(int age):itsAge(age){HowManyCats++;} virtual ~Cat(){HowManyCats--;} virtual int getAge(){return itsAge;} virtual void setAge(int age){itsAge=age;}; static int HowManyCats;private: int itsAge;};// int Cat::HowManyCats=0; //对静态成员数据如... 阅读全文

posted @ 2013-02-18 16:26 mymemory 阅读(227) 评论(0) 推荐(0)

对象初始化

摘要: struct Test{ Test(int){} Test(){} void fun(){cout<<"func"<<endl;}};int main(){ Test a(1); Test b(); //此处是一个函数声明,返回值为Test类型,而不是对象定义! Test b1; //对象定义 Test *c = new Test(); Test *d = new Test(2); a.fun(); b.fun(); //error!c... 阅读全文

posted @ 2013-02-18 16:19 mymemory 阅读(151) 评论(0) 推荐(0)

导航