概念很簡單,以下的constructor寫得不好:
class Person { String _name; int _age; public: Person() { _name = 0; _age = 0; } };因為compiler會把它轉化成以下(*):
Person() { String tmpString(0); // temporary String object been created String _name.String(); _name = tmpString; // copy assignment operator been called tmpString.~String(); // destruct temporary String object _age = 0; // basic data type, set value directly }