Inline functions may be class member functions : inline « Class « C++






Inline functions may be class member functions

Inline functions may be class member functions
 

#include <iostream>
using namespace std;
class myclass {
  int a, b;
public:
  void init(int i, int j);
  void show();
};
// Create an inline function.
inline void myclass::init(int i, int j)
{
  a = i;
  b = j;
}
// Create another inline function.
inline void myclass::show()
{
  cout << a << " " << b << "\n";
}
int main()
{
  myclass x;
  x.init(10, 20);
  x.show();
  return 0;
}

           
         
  








Related examples in the same category

1.Automatic inlineAutomatic inline
2.Create an inline function.Create an inline function.
3.Use inline to make this program more efficient
4.Creating Inline Functions Inside a Class
5.Inline function that calculates the volume of a sphere