UrbanPro
true

Learn C++ Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Macro v/s Inline Function

Darpan Kumar
27/05/2017 0 0

Disadvantages of Macro compared to functions:

  • Works on text substituiton mechanism by the preprocessor unlike normal functions where assembly-language Call and Return are used.
  • Preprocessor macros cannot access class member data and hence they cannot be used as class member functions.
  • Generally confined to functions that can be expressed in a single statement.
  • No type checking is done for macros.

 Inline function:

  • C++ implements macro as inline function.
  • Function definition inside a class definition is automatically inline.
  • Inline function is expanded in place, like a preprocessor macro so that overhead of function call is eliminated.
  • The keyword inline is just a suggestion to the compiler to make the function inline. There are cases when the inilining cannot be performed:
  1. Compiler cannot perform inlining if the function is too complicated.
  2. Compiler cannot perform inlining if the addess of the function is taken implicitly or explicitly. If the compiler must produce an address, then it will allocate storage for the function and use the resulting address.
  3. Compiler does not perform inlining if are static variables used in the function.
  4. Compiler does not perform inlining if there is a recursive function call.
  • Inline functios have internal linkage. The keyword extern has no significance when used with inline functions.
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Do (pre & post)Increment and decrement operators behave differently when printed in the same and different line in C++?
Before I explain anything,I would like you to run the following program. void main() {int j =10; cout<<“j before increment =“<<j; cout<<“++j =“<< ++j; cout<<“...


C++ Program-Single Dimension Array
/* WAP to print sum and largest value in a single dimension array*/ //Header files #include<iostream.h>#include<conio.h> //Main function void main(){ //Array declaration int num,i,sum,large;...

C++ Program-Working with constant using const keyword
//Header files #include<iostream.h>#include<conio.h> //Main function void main(){ //using const keyword to declare constants with a specific type const int len=10; const int br=5; const...

C++ Fundamentals - Introduction
Introduction to C++ C++ CHARACTER SET It is the set of all valid characters that a language can recognize . It represents any letter, digit, or any other sign .C++ character set: LETTERS...
R

Looking for C++ Language Classes?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C++ Language Classes?

The best tutors for C++ Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C++ Language with the Best Tutors

The best Tutors for C++ Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more