7
Inline functions in C+ + Presented by Harish Gyanani

Inline functions in c++

Embed Size (px)

DESCRIPTION

Inline functions in c++ Index- What is inline function? Why use inline function? When to use inline function? How to make a normal function, inline? Inline is a request or command?

Citation preview

Page 1: Inline functions in c++

Inline functions in C++

Presented by Harish Gyanani

Page 2: Inline functions in c++

Index (Questions answered in this ppt)

• What is inline function?• Why use inline function?• When to use inline function?• How to make a normal function, inline?• Inline is a request or command?

Page 3: Inline functions in c++

What is inline function?

• An inline function is a function that is expanded in line when it is invoked.

• The compiler replaces the function call with the corresponding function code.

• If a function is inline, the compiler places a copy of the code of that function at each point where the function is called at compile time.

Page 4: Inline functions in c++

Why use inline function?

To eliminate the cost of calls to small functions, we use inline function.

Page 5: Inline functions in c++

When to use?

The functions are made inline when they are small enough to be defined in one or two lines.

Page 6: Inline functions in c++

How to make a normal function inline?

It is easy to make a function inline. All we need to do is to prefix the keyword inline to the function definition. All inline functions must be defined before they are called.

Page 7: Inline functions in c++

Inline is a request, not a command

The inline keyword merely sends a request, not a command, to the compiler. The compiler may ignore this request if the function definition is too long or too complicated and the function as a normal function.