I was reading a book and it said
"Mac names cannot be overloaded and the macro preprossor cannot handle recursive calls:

#define PRINT (a,b)cout<<(a)<<(b)
#define PRINT (a,b,c) cout<<(a)<<(b)<<(c) /*trouble?:redefines,does not overload*/

Can someone pls explain possibliy with examples?

You can't actually code them as you posted them because the second line will produce a "redefination" error message. Once a macro has been defined you have to undefine it before it can be re-defined.

#define PRINT (a,b)cout<<(a)<<(b)
#undef PRINT
#define PRINT (a,b,c) cout<<(a)<<(b)<<(c) /*trouble?:redefines,does not overload*/

You don't have to define macros at the beginning of a program -- they can be defined, undefined, and re-defined anywhere you want to do it. The compiler will use the most recent definition when compiling the remainder of the program from the point that the macro is defined to the end of the program file.

Macros are evil beasts. One reason is because of what I just said above, that macros can be redefined anywhere in the program making it difficult for a programmer to figure out why something went wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.