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
Compiler Design - Limit In The Method Instructions

The probabilistic Hough transform uses random sampling instead of an accumulator array. In this approach the number of random samples r, is not specified in the OpenCV call, but is

Writing and compiling a program from a given Use Case definition. Follow the Average Temperature in Paradise

write a c program to find input string using strlen(), strcpy(), strcat(),strncat(), strcmp().

give an example of function

What is Ms dos?

in a multilist organisation

Differences between a pointer and a reference 1.  A reference must always point to some object where as this restriction is not imposed on a pointer. e.g. int *pi = 0;

We can combine more than one variable on the same line i.e.   float number1,number2,number3; etc Sometimes we want to mix the variable types used on the same line, this could

HOW TO USE POINTER