标签:cin AC double return add .com end src mes
#include<iostream> using namespace std; class rectangle { public: double area(double l,double w); private: double length,width; }; double rectangle::area(double l,double w) { length=l; width=w; return length*width; } int main() { rectangle Rectangle; double length,width; cin>>length>>width; cout<<Rectangle.area(length,width)<<endl; return 0; }
#include<iostream> using namespace std; class Complex { public: Complex(double r0,double i0){ real=r0; imaginary=i0; }; Complex(Complex &c0); void add(Complex &C0) void show(); private: double real,imaginary; }; void Complex::add(Complex &c0) { real+=c0.real,imaginary+=c0.imaginary; } void Complex::show() { cout<<real‘+‘<<imaginary<<‘i‘<<endl; } int main() { Complex c1(3,5); Complex(4.5); c1.add(c2); c2.show(); return 0; }
标签:cin AC double return add .com end src mes
原文地址:https://www.cnblogs.com/baiyixin/p/8747971.html