forked from ShiqiYu/CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinline.cpp
More file actions
37 lines (29 loc) · 678 Bytes
/
Copy pathinline.cpp
File metadata and controls
37 lines (29 loc) · 678 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
#include <iostream>
using namespace std;
inline float max_function(float a, float b)
{
if (a > b)
return a;
else
return b;
}
//#define MAX_MACRO(a, b) a>b ? a : b
#define MAX_MACRO(a, b) (a)>(b) ? (a) : (b)
int main()
{
int num1 = 20;
int num2 = 30;
int maxv = max_function(num1, num2);
cout << maxv << endl;
maxv = MAX_MACRO(num1, num2);
cout << maxv << endl;
maxv = MAX_MACRO(num1++, num2++);
cout << maxv << endl;
cout << "num1=" << num1 << endl;
cout << "num2=" << num2 << endl;
num1 = 0xAB09;
num2 = 0xEF08;
maxv = MAX_MACRO(num1&0xFF, num2&0xFF);
cout << maxv << endl;
return 0;
}