c++练习(1 - 2)。。。。

我要开发同款
徐宇华2023年07月18日
87阅读
作品源文件
rar格式 27.07 MB
¥2.00

作品详情

#includeclass complex {public: double real, imag; complex(double r, double i) { real = r, imag = i; } complex(complex cx) { this->real = cx.real; this->imag = cx.imag; }};int main() { complex cmlx(3.05f, 1.12f); std::cout << cmlx.real << ": " << cmlx.imag << std::endl; complex cmlx2(cmlx); cmlx2.real -= 1.25f; cmlx2.imag += 1.25f; std::cout << cmlx2.real << ": " << cmlx2.imag << std::endl; return 0;}//------------------------code_njssior---------------------------------#includeclass sampleter {protected: int n;public: sampleter() { std::cout << "note code sampletor;" << std::endl; } sampleter(const sampleter& nnsx1):n(nnsx1.n){ std::cout << this->n++ << "to (n + 1);" << std::endl; this->printf_ttooilr(); } sampleter(int ni):n(ni) { std::cout << n << " suir complxer;" << std::endl; } void printf_ttooilr() { std::cout << n << " suir complxer;" << std::endl; }};int main() { sampleter a, aa(2), b(aa), b22(b); return 0;}
查看全文
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论