C++自编String类代码
#include #include using namespace std; class String { public: String(); String(const char*const); String(int x); String(const String &rs); int getlen()const{return len;} const char* getstr()const{return str;} char& operator[](int lenth); char operator[](int lenth)const; String& operator=(const String &rs); String operator+(const String &); void operator+=(const String &); friend ostream& operatora.str; return i; } ~String(); private: int len; char *str; }; return s; } friend istream& operator>>(istream&i,const String&a) { i>>a.str; return i; } ~String(); private: int len; char *str; };
暂无评论