What is difference among macro and template?, C/C++ Programming

A: In C++ there is a main difference among a template and a macro. Merely a macro is a string which the compiler replaces along with the value that was defined. For example #define STRING_TO_BE_REPLACED "ValueToReplaceWith"

A template is a method to make functions independent of data-types. It cannot be accomplished via macros.

For example a sorting function doesn't have to care whether it's sorting integers or letters as the same algorithm might apply anyway.

 

Posted Date: 3/21/2013 7:25:02 AM | Location : United States







Related Discussions:- What is difference among macro and template?, Assignment Help, Ask Question on What is difference among macro and template?, Get Answer, Expert's Help, What is difference among macro and template? Discussions

Write discussion on What is difference among macro and template?
Your posts are moderated
Related Questions
At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Your program should use the Free Pascal compiler or the Lazarus IDE described in CSC 540. When you hand in your assignment to the digital dropbox, it should be a .PAS file, not zip

A: It is implementation dependent. Verify with your compiler's documentation. For instance, assume you wish to do binary I/O using std::cin & std::cout. Unluckily there is no st

write a program to generate padovan sequence in c++


Define the Volatile Keyword Qualifiers in C Language? The volatile keyword proceed as a data type qualifier and a volatile variable is for dynamic use. E.G. for data that is to


Arguments Passing Mechanism C++ supports the following argument passing mechanisms: i).  Pass by value: A copy of the arguments value is made and passed to the called functio

The program sorting.cpp contains a main function for testing the operation of several sort algorithms over various data sizes and data set organisations. The program understands