c++类中的转换函数的作用是将对象转换为其他类型,如double
Stonewt wolfe(285.7);
double host=wolfe;
Stonewt::operator double()const
{
return (pounds);
}
而类的自动转换是将其他类型转换为类的类型
Stonewt incognito=275
等价于
Stonewt incognito(275)
c++类中的转换函数的作用是将对象转换为其他类型,如double
Stonewt wolfe(285.7);
double host=wolfe;
Stonewt::operator double()const
{
return (pounds);
}
而类的自动转换是将其他类型转换为类的类型
Stonewt incognito=275
等价于
Stonewt incognito(275)