运算符重载问题
61 // concatenate right operand to this object and store in this object62 const String &String::operator+=( const String &right )
63 {
64 size_t newLength = length + right.length; // new length
65 char *tempPtr = new char[ newLength + 1 ]; // create memory
66
67 strcpy( tempPtr, sPtr ); // copy sPtr这里
68 strcpy( tempPtr + length, right.sPtr ); // copy right.sPtr这里
69
70 delete [] sPtr; // reclaim old space
71 sPtr = tempPtr; // assign new array to sPtr
72 length = newLength; // assign new length to length
73 return *this; // enables cascaded calls
74 } // end function operator+=
编译时提示:warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
67行我改成:strcpy_s( tempPtr,newLength+1, sPtr )通过了
68行我不会改,请高手看下!