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

which of the following is not an secondary constant a) array b) real c) union

1266


write a porgram in c++ that reads an integer and print the biggest digit in the number

1773


What are the storage qualifiers?

665


What is a tuple c++?

548


How to defines the function in c++?

621






Give 10 points of differences between C & C++.

627


what are the iterator and generic algorithms.

1463


What is the need of a destructor?

638


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

554


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

1791


What does override mean in c++?

587


Will a catch statement catch a derived exception if it is looking for the base class?

563


Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?

568


Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?

559


How long it will take to learn c++?

618