c++(运算符重载 &&()右移运算符重载)
c++(运算符重载 &&()右移运算符重载)
istream& operator>>(istream& cin, MyString& str)
{
//先清空原有内容
if (str.pString != NULL) {
delete[] str.pString;
str.pString = NULL;
}
//让用户输入的内容
char buf[1024];
cin >> buf;
//把用户输入的新内容拷备到str中
str.pString = new char[strlen(buf) + 1];
strcpy(str.pString, buf);
str.m_Size = strlen(buf);
return cin;
}
浙公网安备 33010602011771号