本文共 836 字,大约阅读时间需要 2 分钟。
using namespace std;class stu{ public: stu(string name,int age){ this->name = name; //用this来指代这个对象的name this->age = age; //name = name; //age = age; //构造器的入参与成员名相同,这样写输出的结果是错误的 } void prin() { cout<< <
连续赋值:a=b=c=d;:sstring &sstring::operator=(const sstring & another) //重载赋值运算符{ if(another._str==_str) return *this; s4 = s4; //这个就调 delete [] _str; int len = strlen(another._str); strcpy(_str,another._str); return *this;}
Stu* const & growUp(){ this->age++; return this;}
转载地址:http://psko.baihongyu.com/