- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinline-function.cpp
More file actions
Latest commit
20 lines (15 loc) · 603 Bytes
/
Copy pathinline-function.cpp
File metadata and controls
20 lines (15 loc) · 603 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// inline function are same line function and macros if there is just only one line of code in function then you can use inline function it actually after comilation replace the inner code
// for example after comilation at line 18 on "result" it will be replaced with "(a > b) ? a : b"
// it actually used to save function call
#include<iostream>
usingnamespacestd;
inlineintmaxVal(int& a, int b) {
return (a > b) ? a : b;
}
intmain() {
int a = 5;
int b = 10;
int result = maxVal(a, b);
cout << "max value is between " << a << " and " << b << "" << result ;
return0;
}