class Complex {
private:
double real;
double img;
public:
Complex(int real, int img);
operator double();
};
Complex::Complex(int real, int img)
{
this->real = real;
this->img = img;
}
Complex::operator double()
{
return real;
}
int main()
{
Complex C(1, 1);
cout<<double(C);
system("pause");
}
C++类型转换函数
最新推荐文章于 2024-05-03 01:02:10 发布