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
WAP TO ACCEPT THE BASIC SALARY OF EMPLOYEES & CALCULATE NET SALARY   #include stdio.h> #include conio.h>   void main() {                    float Basi

What is the difference between structure and class? - Members of structures are public while those of a class are private. - Classes provide data hiding while structures don

Radix sort - C program: Write a program in c to define a radix sort. void main() {  int array[100],n;  int i;  void radix(int *,int);  printf ("How many nos\

Define a structure of student class:  Write a program to define a structure of student record in C. class student { char name[20]; int roll_no; int marks[2];


Illustration of Plot function: To be more common, the script could prompt the user for the time and temperature, instead of just assigning the values. Then, the axis function

wap to count the numof string present in a word

i need amibroker afl to dll plugin

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

THIS PROGRAM IS TO COMPARE THE TWO DATES GIVEN BY THE USER #include #include #include struct date  {   int dd;   int mm;   int yy;  }; date compare(date d1,date d2)  {