1. 程式人生 > >運算子過載引數的順序對運算是否有影響

運算子過載引數的順序對運算是否有影響

//declaration friend String & operator+(const char * schar, String & st); //defination String & operator+(const char * schar, String & st) {     char * tempString = new char[strlen(st.str) + strlen(schar) + 1];     strcpy(tempString, schar);     strcat(tempString, st.str);     String * temp = new String(tempString);     delete [] tempString;     return *temp; } //application String s1("ZJS"); String s2; s2 = "My name is " + s1;