Use inline to make this program more efficient : inline « Class « C++






Use inline to make this program more efficient

  
#include <iostream>  
using namespace std;     
class MyClass {  
  int i; 
public:  
  int get_i(void);  
  void put_i(int j);  
} ;  
     
inline int MyClass::get_i(void){
  return i;  
}
     
inline void MyClass::put_i(int j){  
  i = j;  
}
    
main(void){  
  MyClass s;  
     
  s.put_i(10);  
  cout << s.get_i();  
     
  return 0;  
}
  
    
  








Related examples in the same category

1.Inline functions may be class member functionsInline functions may be class member functions
2.Automatic inlineAutomatic inline
3.Create an inline function.Create an inline function.
4.Creating Inline Functions Inside a Class
5.Inline function that calculates the volume of a sphere