标签:add ios 函数 namespace 图片 .sh pre alt mic
#include<iostream> #include<cmath> using namespace std; class Complex { public: Complex(double x0 = 0.0, double y0 = 0.0); Complex(Complex &C); void add(Complex C); void show(); double mod(); private: double x; double y; }; Complex::Complex(double x0, double y0) : x(x0), y(y0){}; Complex::Complex(Complex &C) { x = C.x; y = C.y; } void Complex::add(Complex C) { x = x + C.x; y = y + C.y; } void Complex::show() { cout << x<< "+" << y << "i" << endl; } double Complex::mod() { return sqrt(x*x+y*y); } int main() { Complex c1(3, 5); Complex c2=4.5; Complex c3(c1); c1.add(c2); c1.show(); cout << c1.mod(); return 0; }
标签:add ios 函数 namespace 图片 .sh pre alt mic
原文地址:https://www.cnblogs.com/aiwenzhuo/p/10631422.html