Dear i want to know can at what extent we can make a complex function as a macro for ex. getFromString(CString s, LPCTSTR delemiter) { CString temp; int m= s.findof(delemiter); if(m!=-1) temp= s.mid(m); }
Well, this particular one would be like this: #define GET_FROM_STRING(s, delim) \ {\ CString temp;\ int m= s.findof(delemiter);\ if(m!=-1)\ temp= s.mid(m);\ } Note the \ symbols - they concatenate physical source lines. But making a macro out of such a funvtion is a horrible idea, because macros don't have scope, their parameters don't have types and, of course many surprising results can occur due to literal text substitution.
I will repeat myself, DON"T use a macro unless you have to. In this particular case an inline function (a function delcared with the keyword inline, and defined in the same ".h" file) is a superior alternative.