class Stock10 {
private:
int t = 1;
public:
friend ostream& operator<<(ostream&, const Stock10&);
Stock10(int _t);
operator double();
};
Stock10::operator double() {
return t;
}
Stock10 s1 = 10; //构造函数加explicit,则禁用这种转换
double t2 = s1;
operator double();
将类转换成相应的数据类型
与输值=操作符相反