摘要: 1 //代码参考C++primer. 2 3 4 5 #include<iostream> 6 7 using namespace std; 8 9 10 11 class String{ 12 13 friend ostream& operator<< (ostream&,String&); 14 15 public: 16 17 String(const char* str=NULL); //赋值构造兼默认构造函数(char) 18 19 String(const String &other)... 阅读全文
posted @ 2011-11-09 11:09 Clin 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include <string.h> 3 4 class String 5 { 6 public: 7 String(const char *str = NULL); 8 ~String(); 9 String(const String &other);10 String& operator = (const String &other);11 private:12 char *m_data;13 };14 15 String::~String()16 {17 delete [] m_data;.. 阅读全文
posted @ 2011-11-09 11:08 Clin 阅读(153) 评论(0) 推荐(0) 编辑