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 is fixed in c++?

580


Can we make copy constructor private in c++?

591


What is #include iostream h in c++?

605


What is difference between n and endl in c++?

579


What is the difference between a declaration and a definition?

577






What new()is different from malloc()?

565


How is objective c different from c++?

784


What is the basic structure of a c++ program?

606


Can class objects be passed as function arguments?

597


What apps are written in c++?

599


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

548


How do you define a class in c++?

637


Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .

673


What is virtual destructor ans explain its use?

598


why is c++ called oops? Explain

578