#include <iostream>
using namespace std;
class Complex {
public: Complex(int a,int b)
{re=a;im=b;};
Complex (float a){
storea=a;};
void add(Complex p) {
re+=p.storea;}
void show(){
cout<<re<<" + "<<im<<"i"<<endl;
}
private:float re,im;
float storea;
};
/////////////////////////////////////////////
int main () {
Complex c1(3,5);
Complex c2=4.5;
c1.add(c2);
c1.show();
}
时间: 2024-10-09 13:57:01