Feeling
String STR (" hello "); And the String STR="hello"; Is the assignment operation
CodePudding user response:
You see books written inside, the former is the copy constructor, the latter is through operator overloading "=" realize the assignment of functions,CodePudding user response:
Distinguish between structure and assignment,In a narrow sense said:
Structure is initialized, detail and have a lot of concepts, what values as initialization, initialization, directly copy initialization, aggregate initialization, initialization list... Reference:
https://en.cppreference.com/w/cpp/language/initialization; Say from another aspect and display initialization, implicitly initialized,
Assignment was conducted after initialization change integral value, is called copy assignment, the whole copy, only the operator=,
Difference between structure and the key of the assignment is that structure is a statement in the time of initial value,
So only copy, copy assignment, no copy assignment,
` ` `
String STR (" hello ");//there is type declaration in front, followed by parentheses can also see that must have been constructed, this is called structure directly, also showed that the structure,
String STR="hello".//in front of a type declaration, it must be constructed, with the=sign, is an implicit structure, implicit call with direct constructor String (const char *)
` ` `
CodePudding user response: