hi,
ineed to know what is wrong with this macro definition
#define fac(a) (a)*fac((a)-1)
hi,
ineed to know what is wrong with this macro definition
#define fac(a) (a)*fac((a)-1)
"If knowledge can create problems, it is not through ignorance that we can solve them. "
-Isaac Asimov(1920-1992)
You cannot put recursion in a define. What the compiler does is run through the complete code and replace all defines.
So fac(10) is replaced by: (10)*fac((10)-1)
Remember that this is compiletime, not runtime, so the compiler does nothing with the value 10.
After this you will get a link error because the fac function cannot be found.
Using macros in C++ is far from perfect. I reckon you should consider using inline functions.