摘要: #include #includeusing namespace std;class String{ int length; int i;private: char* m_data;//用于保护字符串 public: String(const char *str=NULL)//普通构造函数 { cout<<"调用了构造函数"<<endl; if(str==NULL) { length=0; m_data=new char(1); //指针指向这段空间 ... 阅读全文
posted @ 2013-07-17 12:33 ymonke 阅读(636) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;class B {public: B(int i){coutusingnamespacestd;class A{public: A() { coutfunc(); //A::func a->func1(); //B::func B b; //A B A::func b.func(); //A::func //B析构 //A析构} 而上面的这个例子又是另外一种情况,类B公有继承类A,那么B如果创建一个对象必须得先调用父类A... 阅读全文
posted @ 2013-07-17 11:46 ymonke 阅读(282) 评论(0) 推荐(0) 编辑