Question: In what two ways can an object of type A be automatically converted into an object of B in C++? The answer: .... (the first method omitted) Another method is needed if we wish to be able to convert into objects of type B when the class declaration is not accessible, for example, suppose B was the type double: we cannot write a new constructor for doubles. This is done by defining an operator in the class A whose name is B so we include the line operator B() const; in the class declaration for A. When we define the operator, we code it as B::operator A() const; { // create object of type B and return it ... } 这个答案是不是就是在A里面定义一个函数成员,来overload B()呢? 如果B是double,这个declaration就是 operator double() const; 后面那句答案是不是写反了?我觉得应该是 A::operator B() const;