Computer Science, asked by Archyanwar4219, 1 year ago

Advantages of a macro over a function?

Answers

Answered by rupali8153gmailcom2
4
One advantage is that You can use simple small names for a number of statements. You can even define macros for functions. When writing macros for functions, they saves a lot of time that is spent by the compiler for invoking / calling the functions. Hence, The advantage of a macro over an actual function, is speed.
Answered by AshuAce
5

Is there any advantage of using macros in C++?

Macros are used as text substitution. One advantage is that You can use simple small names for a number of statements. You can even define macros for functions.

When writing macros for functions, they saves a lot of time that is spent by the compiler for invoking / calling the functions. Hence, The advantage of a macro over an actual function, is speed. No time is taken up in passing control to a new function, because control never leaves the home function. The macro just makes the function a bit longer. Macros may make compiling slower but the compiled programs are faster.

Please Mark this Brainliest and Follow me please

Similar questions