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;
}

posted on 2021-04-24 11:09  lodger47  阅读(280)  评论(0)    收藏  举报

导航