虽然在operator const char*() const 中也是重载()运算符,但是这里的这个()运算符叫类型转换运算符(type conversion operator),而不是一楼所说的函数运算符(call operator)。两个虽然长得一样,可是用法完全不同。
基于8个网页-相关网页
compulsory type conversion operator 强制类型转换运算符
For a type conversion operator, either the operand or the return type must be of the data type of the class or structure.
对于类型转换运算符,操作数或返回类型必须是类或结构的数据类型。
The implicit conversion operator is defined, which converts a Point type to int.
隐式转换操作符将 Point 类型转换为 int。
A definition of a conversion operator that returns the type of your class or structure.
一个转换运算符的定义,返回您的类或结构的类型。
应用推荐