how to write an inline class member functionin


How to write an inline class member function

In addition to global functions, you may request that non-static member functions of a class be inlined.  The normal method of doing this is to simply define the function within the scope of the class definition.  In this case the inline request is made automatically, so the keyword inline does not require to be written.

Here the member function integer:: store ( ) is an inline member function because it is completely explained within the context of the class definition.

e.g.

Class integer

{

      public:

                                 //  This is an inline function

 

Void store (int n )

                                { 

                                number =n ;

                }

      private:

                   int number ;

  };

Functions inlined within the class definition are not evaluated by the compiler unless the entire class scope has been processed.  That's why, if they are explained first, they can refer to members defined later, or even compute the size of the class. The only problem with this class is that now it has been " cluttered up" with the actual definition of the integer:: store() function. 

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: how to write an inline class member functionin
Reference No:- TGS0309485

Expected delivery within 24 Hours