2013年4月9日

摘要: #include<iostream.h> //注意这里使用带h的头文件,不然在vc里编译通不过 //再次强调下,只要是在classmember中有pointer的存在,class就应该提供copyconstructor和operator=.class A{public: A():data(0){}; A(A &b) { cout << "copy constructor" << endl; data = b.data + 2; } A(int _data):data(_data){}; A&... 阅读全文
posted @ 2013-04-09 21:28 江在路上 阅读(138) 评论(0) 推荐(0) 编辑
 
摘要: 1、#include<iostream>using namespace std;class A{public: virtual void f() { cout<<"A::f()"<<endl; } void f() const { cout<<"A::f() const"<<endl; }};class B: public A{public: void f() { cout<<"B::f()"<<endl; } void f() const { cou 阅读全文
posted @ 2013-04-09 19:54 江在路上 阅读(192) 评论(0) 推荐(0) 编辑