- 博客(7)
- 收藏
- 关注
原创 单目运算符重载为友元函数
#include<iostream>using namespace std;class point{private: int x,y;public: point(int xx=0,int yy=0) {x=xx;y=yy;} void display(){cout<<"x="<<x<<",y="<&a
2018-07-23 15:39:22 1865 1
原创 单目运算符重载为成员函数
#include<iostream>using namespace std;class point{private: int x,y;public: point(int xx=0,int yy=0) {x=xx;y=yy;} point operator ++(int)//后置++加上一个int 前置不用加 { x+...
2018-07-23 15:08:36 763
原创 this 指向当前对象,通过它可以访问当前对象的所有成员。
#include<iostream>using namespace std;class eg{private: int a;public: eg(int b) {a=b;} void add (int m) { eg p(5); p.a=p.a+m; *this=p;//this指...
2018-07-23 14:47:51 1771
原创 运算符重载实现复数的相加减
#include<iostream>using namespace std;class complex{private: double real; double imag;public: complex(double r=0,double i=0):real(r),imag(i){} complex operator + (complex &a...
2018-07-23 00:43:37 3000
原创 类的组合:computer
#include<iostream>using namespace std;enum RAM_Type {DDR2=2, DDR3, DDR4};enum CPU_Rank {P1,P2,P3,P4,P5,P6};enum ROM_Type{SATA,USB};enum ROM_Installation{external,builtin};class RAM{priva...
2018-07-20 15:01:45 854
原创 枚举类
//不同枚举类中枚举常量值有相同的名字不会发生冲突,普通枚举类型会冲突#include<iostream>using namespace std;enum class Side(Right,Left);enum class Thing(Wrong,Right);int main(){ Side s=Side::Right; Thing w=Thing::R...
2018-07-20 01:30:00 82
原创 类的组合 计算线段长度
#include<iostream>#include<math.h>using namespace std;class Point{private: int x,y;public: Point(int xx,int yy) {x=xx;y=yy;} int getx() {return x;} int gety()...
2018-07-19 18:12:50 1761
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人