• +91 9723535972
  • info@interviewmaterial.com

C Interview Questions and Answers

Question - What is difference between template and macro??

Answer - There is no way for the compiler to verify that the macro parameters are of compatible types. The macro is expanded without any special type checking. If macro parameter has a postincremented variable ( like c++ ), the increment is performed two times. Because macros are expanded by the preprocessor, compiler error messages will refer to the expanded macro, rather than the macro definition itself. Also, the macro will show up in expanded form during debugging. for example: Macro: #define min(i, j) (i < j ? i : j) template: template T min (T i, T j) { return i < j ? i : j; }

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners