forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFunction.h
More file actions
45 lines (35 loc) · 777 Bytes
/
MyFunction.h
File metadata and controls
45 lines (35 loc) · 777 Bytes
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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: MyFunction.h
@Time: 2021/9/2 11:20 下午
@Desc:
***************************/
#ifndef CGRAPH_MYFUNCTION_H
#define CGRAPH_MYFUNCTION_H
int add(int i, int j) {
return i + j;
}
static float minusBy5(float i) {
return i - 5.0f;
}
class MyFunction {
public:
std::string pow2(std::string& str) const {
int result = 1;
int pow = power_;
while (pow--) {
result *= atoi(str.c_str());
}
return "multiply result is : " + std::to_string(result);
}
static int divide(int i, int j) {
if (0 == j) {
return 0;
}
return i / j;
}
private:
int power_ = 2;
};
#endif //CGRAPH_MYFUNCTION_H