#include <iostream>
using  namespace std;
class Complex
{
private:
	double real;
	double imag;
public:
	Complex();
	Complex(double r,double i);
	operator double()                            //定义类型转换函数
	{
		return real;
	}
};
int main()
{
	Complex t1(1,2);                             //定义对象t1
	Complex t2(3,4);                             //定义对象t2
Complex t3;                                //定义对象t3
	double c,d;                                 //定义double类型的变量c,d
	c=3.5+t1;                                  //调用类型转换函数
	d=t1+t2;                                   //调用类型转换函数
	cout<<"c: "<<c<<endl;
	cout<<"d: "<<d<<endl;
	return 0;
}
Complex::Complex()
{
	real=0;
	imag=0;
}
Complex::Complex(double r,double i)
{
	real=r;
	imag=i;
}

