Using an inline function to calculate the volume of a cube. : inline « Class « C++ Tutorial






#include <iostream>

using std::cout;
using std::cin;
using std::endl;

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

int main()
{
  double side;

  for ( int k = 1; k < 4; k++ ) {
      cout << "Volume of cube with side " << k << " is " << cube( k ) << endl;
  }

   return 0;
}








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.