实战提升:PHP 7.0版解决开发者日常问题的高级教程

1星 需积分: 32 96 下载量 28 浏览量 更新于2024-07-20 2 收藏 20.06MB PDF 举报
"《PHP.7.Real.World.Application.Development.2016.9》是一本专门针对PHP 7版本进行深入讲解的实战开发教程。该课程由三个模块组成,每个模块都是一个独立的小课程,旨在提升开发者的基础到中级乃至高级的PHP编程技能,特别是着重于PHP 7的新特性和优化。 第一模块,编程手册形式,包含超过80个实用的编程“菜谱”,旨在解决PHP开发者在日常工作中遇到的实实在在的问题,这些“菜谱”展示了如何利用PHP 7的新功能编写高效、易维护的代码。学习者将学会处理常见问题的解决方案,如性能优化和代码重构等。 第二模块关注的是应用性能和生产力的提升。课程会引导读者理解和运用PHP 7中的面向对象编程(OOP)概念,以及如何优化PHP 7应用程序和数据库性能。在这个模块中,学员还将接触到基准测试工具,以便对代码性能有更准确的评估和改进策略。 第三模块深入探讨模块化编程理念,指导如何在PHP代码中实现模块化设计,这有助于构建可读性强、易于管理、可重用且效率更高的代码。通过学习,开发者可以利用PHP 7的开源特性,创建模块化的函数和组件,提高软件项目的整体结构和质量。 整本书的版权信息表明,所有内容均需获得出版商Packt Publishing的书面许可才能复制或传播,以确保课程内容的准确性和原创性。尽管作者和出版社尽力确保信息的准确性,但课程不提供任何形式的保修,也不承担因课程内容导致的直接或间接损失的责任。 Packt Publishing在课程中尽力提供商标信息,但不能保证所有提及的公司和产品的商标权归属。《PHP.7.Real.World.Application.Development.2016.9》是一本实用且有针对性的教材,适合希望升级PHP技能并应用于实际项目中的开发者,无论是初学者还是经验丰富的专业人员。"

把下面代码的运算符重载改为友元函数形式#include<iostream> using namespace std; class complex { private: double real; double imag; public: complex(double r = 0.0, double i = 0.0); void print(); complex operator -=(complex c); complex operator *=(complex c); complex operator /=(complex c); complex operator ++(); complex operator ++(int); }; complex::complex(double r, double i) { real = r; imag = i; } complex complex::operator -=(complex c) { complex temp; temp.real = real - c.real; temp.imag = imag - c.imag; real = temp.real; imag = temp.imag; return temp; } complex complex::operator *=(complex c) { complex temp; temp.real = real * c.real - imag * c.imag; temp.imag = real * c.imag + imag * c.real; real = temp.real; imag = temp.imag; return temp; } complex complex::operator /=(complex c) { complex temp; double d; d = c.real * c.real + c.imag * c.imag; temp.real = (real * c.real + imag * c.imag) / d; temp.imag = (c.real * imag - real * c.imag) / d; real = temp.real; imag = temp.imag; return temp; } complex complex::operator ++() { complex temp; temp.real = ++real; temp.imag = ++imag; return temp; } complex complex::operator ++(int) { complex temp(real, imag); real++; imag++; return temp; } void complex::print() { cout << real; if (imag >= 0) cout << '+'; cout << imag << 'i' << endl; } int main() { complex A(30, 40), B(15, 30),C; C = A.operator++(1); cout << "C=A++后,C为:"; C.print(); cout << "A为:"; A.print(); C = A.operator++(); cout << "C=++A后,C为:"; C.print(); cout << "A为:"; A.print(); A *= B; cout << "A*=B后,A为:"; A.print(); A /= B; cout << "A/=B后,A为: "; A.print(); cout << "B为:"; B.print(); return 0; }

2023-05-12 上传