#include <iostream> using namespace std; class Complex { private: double real,imag; public: Complex(double r=0,double i=0):real(r),imag(i){} operator double(){return real;} //返回类型为重载类型 //double n=2+c; //double n=2+c.operator double(); }
2023-12-26 23:10:45
#include <iostream> using namespace std; class Complex { private: double real,imag; public: Complex(double r=0,double i=0):real(r),imag(i){} operator double(){return real;} //返回类型为重载类型 //double n=2+c; //double n=2+c.operator double(); }