Inline Member Functions Assignment Help

Assignment Help: >> Classes and Objects - Inline Member Functions

Inline Member Functions

The keyword inline is used as a function specifier only in function declarations. The inline specifier is a suggestion to the compiler in which inline substitution of the function body is to be preferred to the general function call implementation.

The benefits of using inline member functions are:

1.   The size of the object code is considerably decreased.

2.   Inline increases the execution speed

3.   The inline member functions are compact functions calls.

The general form is:

class user_name

{

//data variables;

public:

inline function return_type function name (parameters);

//other member functions;

}

Every time a function is declared along with inline specifier, the C++compiler merely replaces that function with the code itself so the overhead of the transfer of control among the calling portion of a program and a function is decreased.

// demonstration of inline function

# include <iostream.h>

class sample

{

int x;

public:

}

inline void getdata( );

inline void display ( );

inline void sample :: getdata ( )

{

cout<<" enter a number"<<endl;

cin>>x;

}

inline void sample:: display ( )

{

cout<<"entered number is = "<<x<<endl;

}

void main( )

{

sample ob; ob.getdata ( ); ob.display ( );

}

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd