
412 Fundamentals of Computer Programming and IT
16.12 RULES FOR INLINE FUNCTIONS
1. Use inline functions rarely. Apply only under appropriate circumstances.
2. Inline function can be used when the member function contains few statements. For example,
inline int item :: square (int x)
{
return (x*x);
}
3. If function takes more time to execute, then it must be declared as inline. The following inline function
cannot be expanded as inline:
inline void item:: show()
{
cout <<“\n Codeno =”<<codeno;
int qty;
public: // public section starts
void show (void); // prototype declaration
}; // end of class
inline void item:: show () // outside inline ...