inline method : inline « Class « C++ Tutorial






#include <iostream> 
using namespace std; 
 
class MyClass { 
  int i; // private by default 
public: 
  int getInt(); 
  void setInt(int j); 
} ; 
 
inline int MyClass::getInt() 
{ 
  return i; 
} 
 
inline void MyClass::setInt(int j) 
{ 
  i = j; 
} 
 
int main() 
{ 
  MyClass s; 
 
  s.setInt(10); 
  cout << s.getInt(); 
 
  return 0; 
}
10








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.