inline functions : inline « Class « C++ Tutorial






#include <iostream>
 
 inline int f(int);
 int main()
 {
     int target;
 
     std::cout << "Enter a number to work with: ";
     std::cin >> target;
     std::cout << "\n";
 
     target = f(target);
     std::cout << "Target: " << target << std::endl;
 
     target = f(target);
     std::cout << "Target: " << target << std::endl;
     
     target = f(target);
     std::cout << "Target: " << target << std::endl;
     return 0;
 }
 
 int f(int target)
 {
     return 2*target;
 }
Enter a number to work with: 12

Target: 24
Target: 48
Target: 96








9.24.inline
9.24.1.inline functions
9.24.2.inline function definiton
9.24.3.inline method
9.24.4.Automatic inline functions
9.24.5.Defines constructor, destructor, and range() function in-line
9.24.6.Using an inline function to calculate the volume of a cube.