cout<& lt; S1. The display () & lt; & lt; endl;
# include
# include
using namespace std;
The class String {
Public:
String (String STR)
: _str (STR)
{
cout<" Sting () "& lt; & lt; endl;
}
String operator=(const String & amp; Str2) {
Return a String (_str=str2. _str); }
Void the display () const {
cout<& lt; _str & lt; & lt; endl;
}
Private:
String _str;
};
Int main () {
String s1 (" hello ");
String s2 (" world ");
cout<" Before phrase "& lt; & lt; endl;
cout<& lt; S1. The display () & lt; & lt; endl;
//cout<& lt; S2. The display () & lt; & lt; endl;
S1=s2;
cout<" After overload "& lt; & lt; endl;
//cout<& lt; S1. The display () & lt; & lt; endl;
//cout<& lt; S2. The display () & lt; & lt; endl;
}