1A function specifier that indicates to the compiler that inline substitution
2of the function body is to be preferred to the usual function call
3implementation
1#include <iostream>
2
3using namespace std;
4
5inline int Max(int x, int y) {
6 return (x > y)? x : y;
7}
8
9// Main function for the program
10int main() {
11 cout << "Max (20,10): " << Max(20,10) << endl;
12 cout << "Max (0,200): " << Max(0,200) << endl;
13 cout << "Max (100,1010): " << Max(100,1010) << endl;
14
15 return 0;
16}
1#include <iostream>
2using namespace std;
3inline int cube(int s)
4{
5 return s*s*s;
6}
7int main()
8{
9 cout << "The cube of 3 is: " << cube(3) << "\n";
10 return 0;
11} //Output: The cube of 3 is: 27
12
1Inline Member Functions (C++)
2A member function that is both declared and defined in the class member list is called an inline member function. Member functions containing a few lines of code are usually declared inline.
3