# include
using namespace std;
The class String
{
Public:
String () {p=NULL; }
String STR (char *);
Void the display ();
Private:
Char * p;
};
String: : String STR (char *)
{
P=STR.
}
Void String: : display ()
{
Cout & lt; }
Int main ()
{
String string1 (" Hello "), string2 (" Book ");
String1. The display ();
Cout & lt;String2. The display ();
return 0;
}
Tan Haoqiang book of the same code, the generation times wrong, why? And how should change? Thank you very much!!!!!!

CodePudding user response:
String (const char *)CodePudding user response:
"Hello" literal is a const pointer, upstairs positive solutions