class String{ public: friend istream& operator >>(istream& intput,const String& s); private: char* Cstr; };
Cstr在使用前有没有申请内存空间?Cstr在类中只声明了,但是没有申请内存空间s.Cstr = new char[100];//100这个数根据实际需要来设置input >> s.Cstr;
char* Cstr; 只有指针,没有分配内存空间。