北京大学程序创新设计实习-习题课.pptVIP

  • 0
  • 0
  • 约1.66万字
  • 约 42页
  • 2019-08-19 发布于广东
  • 举报
MyString operator+(const char *s) // +号重载,这里表示 //MyString类型+字符串的情形 { char *q; q = new char[strlen(p) + strlen(s) + 1]; strcpy(q, p); strcat(q, s); MyString temp(q); delete []q; return temp; } MyString operator=(const MyString s) // 赋值号重载 { if(p!=NULL) { delete[]p; } p = new char[strlen(s.p)+1]; strcpy(p, s.p); return *this; }0 Mystring类(3) 继承和多态— 作业四 char operator[](int n) // []号重载 { return p[n]; } MyString operator+=(char *s) // +=号重载 { char *q; q = new char[st

文档评论(0)

1亿VIP精品文档

相关文档