正在加载图片...
String string operator=( String ob)i /赋值:从已有串ob复制 if &ob!=this)( delete l ch ch= new char[ maxLen+1;/重新分配 if( ch== NULL) cerr<<“内存不足m”;exi(1); curlen =ob, curlen /复制 strcpy( ch, ob. ch ) else cout<<“字符串自身赋值出错!Ⅷm”; return *thiString& String :: operator = ( String& ob ) { //串赋值:从已有串ob复制 if ( &ob != this ) { delete [ ] ch; ch = new char [maxLen+1]; //重新分配 if ( ch == NULL ) { cerr << “内存不足!\n ”; exit (1);} curLen = ob.curLen; //串复制 strcpy ( ch, ob.ch ); } else cout << “字符串自身赋值出错! \n”; return *this; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有