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

Set 0 To Kth Bit In A Variable
The following code snippet Set 0 to Kth Bit in an variable #include int UnsetBitValue(int n, int k);int main(){ printf("%d\n\n",UnsetBitValue(255,6)); return 0;}// Set kth bit to zeroint UnsetBitValue(int...

Contents Of C++ Programming
1. History of CPP 2. Concepts of OOP's 3. Introduction and Features of CPP (OOP's) 4. Characteristics of OOP's 5. CPP Keywords 6. Major Components of CPP: Encapsulation Inheritance Polymorphism 7....

All About Programming And A Good Programmer.
Hi, This is my first lesson for you guys. Hope you enjoy reading it. In recent community questions, I found many people wanted to be good programmers, or wanted to have good hands on certain language,...

Software Development Training In Jaipur
Satyam Web Solution provides website designing &development and software designing &development training in Jaipur for various stream’s students. MCA 6 month Industrial Training/Internship B....

C++ Program-Factorial
//Header files #include<iostream.h>#include<conio.h> //Main function void main(){ int num,i; long factorial=1; //Function for clearing screen clrscr(); cout<< "Enter a number:";...
S

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