-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.h
156 lines (137 loc) · 2.86 KB
/
1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* @Author: ‘15071832337’ ‘[email protected]’
* @Date: 2022-07-27 10:01:58
* @LastEditors: ‘15071832337’ ‘[email protected]’
* @LastEditTime: 2022-08-09 09:39:59
* @FilePath: \code(C++)\vscode\1.h
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
using namespace std;
int jiecheng_jisuan1();
void a1();
void a2();
void a3();
void a6();
void swap1(int& i,int& j);
void swapshow1();
void swapshow2();
void swap2(int *p,int*q);
void show2();
void swap3(int x,int y);
void a9();
void a7();
void a8();
int jiecheng_jisuan(int x);
void print(const char *cp);
void printshow();
void CompareIntNumberAndIntPointNumber1(int &x,int *y);
void CompareIntNumberAndIntPointNumber2();
void ToChangePoint(int *x,int *y);
int DeGuiDiaoYong(int val);
void DeGuiDiaoYongShow();
void TheValuEqualXiaBiao();
int TheValuEqualXiaBiao(int );
void BeginAndToShowArr();
void MaxSumOfArr();
void ConstUser(int);
void ConstShow();
void MidShow(int,int,int);
void NiXuOutPutArr(int size);
void MoveArr(int);
void SharingCandy(int);
void LightChange();
void TwoArrShow(int, int);
int F(int,int);
void test01();
void test02();
void test03();
void test04();
void test05();
template<typename T>
void S(T &a,T &b);
//定义了一个类
//关键字class
class abc//类名
{
public://访问修饰符
int x;//成员变量
int y;
void LightChange();//成员方法
protected://受保护成员
void MoveArr(int);
private://私有成员
void MaxSumOfArr();
public://公有成员
void TwoArrShow(int, int);
void SharingCandy(int);
int TheValuEqualXiaBiao(int );
};
//继承上类
class bcd:public abc
{
private:
public:
void MidShow(int,int,int);
};
class Person1
{
public:
Person1(int age){
this->age=age;
//this 指向被调用的成员函数所指向的对象 即对象p1
}//形参的age和属性的age进行了区分
int age;
Person1& PersonAddAge(Person1 &p){
this->age+=p.age;
return *this;
}
};
class Person2
{
private:
/* data */
public:
int m_A;
int m_B;
/*
Person2 operator+(Person2 &p){
Person2 temp;
temp.m_A=this->m_A+p.m_A;
temp.m_B=this->m_B+p.m_B;
return temp;
}
*/
};
class Animal
{
private:
/* data */
public:
virtual void speak(){
cout<<"the animal speak"<<endl;
}
};
class Cat:public Animal
{
private:
/* data */
public:
void speak(){
cout<<"cat speak"<<endl;
}
};
//地址早绑定,在编译阶段就确定了函数的地址
void doSpeak(Animal &animal){
animal.speak();
}
//为了处理子类和父类的同名函数谁执行的问题,采用
//virtual地址晚绑定
class Dog:public Animal
{
private:
/* data */
public:
void speak(){
cout<<"Dog speak"<<endl;
}
};