Differences between inline functions and non-inline functions?

Answer Posted / madhu

Actually inline functions are used to overcome the demerits
of preprocessor macros and non-inline functions.
Whenever a function call is made function address, formal
arguments and return address will be stored in the stack.
Which leads the overhead to the compiler. To overcome this
inline functions are introduced.

Inline functions are the requester to the compiler to
replace the function definition at the function callers.
Here it is same as preprocessor macros but not equal to 100%
to macros.
The decision of implementing inline is done by compiler.
Points to be consider b/w inline && non-inline functions:
1. inline executes faster than non-inline functions.
2. Using inline will increase the code size than the
non-inline functions.
3. inline are ignored if the function definition contains
more code or loops or conditions.
4. if you define a function inside the class by default it
will treat it as a inline.

Is This Answer Correct ?    34 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are benefits of oop?

639


What is the use of oops?

619


What is destructor give example?

603


How can you overcome the diamond problem in inheritance?

768


What is ambiguity in inheritance?

625






What is difference between inheritance and polymorphism?

571


Explain virtual inheritance?

682


What is property in oops?

568


What are the features of oop?

637


#include #include #include #include void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

3248


Explain the advantages of inheritance.

673


How do you define social class?

600


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1639


Do you know about multiple inheritance?

639


What is meant by multiple inheritance?

738