difference between macro and function?

Answer Posted / soruabh

When you call a function your compiler enters a
call-sequence (which takes
time) and allocates a new stack frame for that function
(whcih takes text
stack space) so that the function's body can be executed.
After it's done
you enter a returning-sequence phase (which takes time).



A macro does not need anything of the above, because it's
preprocessor's job
to expand a macro, it's only about text replacement, not
about compiler
stuff or code-generating issues. So you don't expend time
and space doing
what a function would need in order to be executed.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the sizes and ranges of the basic c++ data types?

683


What is cin clear () in c++?

708


. If employee B is the boss of A and C is the boss of B and D is the boss of C and E is the boss of D. Then write a program using the Database such that if an employee name is Asked to Display it also display his bosses with his name. For eg. If C is displayed it should also display D and E with C?

2879


What is the best c++ book?

802


what are the types of Member Functions?

719






Distinguish between a # include and #define.

754


When are exception objects created?

687


Why iomanip is used in c++?

738


What does new in c++ do?

650


What is a block in c++?

647


What is a class definition?

704


What is #include iostream h in c++?

729


What is private public protected in c++?

629


What is data binding in c++?

596


What is the object serialization?

736