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

Efficient Learning Strategies
Type your notes after class Write your notes onto flashcards - Scrabble -Make posters Review flashcards while walking, at gym, etc. Dog-ear pages in the reading where you can find...

Why do pointers have a datatype?
Before we start with pointers you must know what is a variable and a datatype. int a; This is the basic line in every program in 'C' . It means that we are asking the compiler to give us 2 bytes of space...

Array vs Linked List
Array Linked List Accessing element is easy. Accessing element is difficult compare to Array. Easy to use. Difficult to use. Memory is Fixed size. Memory is variable size. If...

Static and dynamic libraries
A library is a package of code that is meant to be reused by many programs. A static library (also known as an archive) consists of routines that are compiled and linked directly into your program. When...

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...
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