Home > Back-end > There seems to be a mistake in the Effective C
There seems to be a mistake in the Effective C
Time:10-06
In the third edition item35, "Effective c + + Chinese version of" the third sentence code on page 175 EyeCandyCharacter ecc1 (HealthCalculator ()); It seems to be wrong, the author aims to define a class object ecc1 But here the compiler will argue that this code is a function declaration,
I do not know if seen Effective c + + classmates
CodePudding user response:
Know the students give back to a, study together, the points of what are small
CodePudding user response:
No problem, the function declarations must have the type of parameter, such as: MyClass test1 (int);//test1 is a function parameter is int, the return value is the MyClass
Int GetIntValue () {return 1; } MyClass test2 (GetIntValue ());//test2 is an instance of the MyClass, initialized with function GetIntValue return values