Example: C++ inline functions

// Using an inline function to calculate
// the volume of a cube

#include<iostream>

using namespace std;

inline double cube( const double s ) { return s * s * s; }

int main()
{
   double side;
   
   cout << "\n Enter the side length of your cube: ";
   
   cin >> side;

   cout << "\n Volume of cube with side "
        << side << " is " << cube( side ) << endl;


   // inline function, cube(), would be inserted here
   // like this:
   // 
   //    const double s = side;
   //    cout << "\n Volume of cube with side "
   //         << side << " is " << s * s * s << endl;
   

   return 0;
}