I'm using this MACRO for debugging in C++ . Printing the variable name and value. Can anyone explain its working ?
#define watch(x) cout << (#x) << " is " << (x) << endl;
int t = 90;
watch(t);
// output is
t is 90
I'm using this MACRO for debugging in C++ . Printing the variable name and value. Can anyone explain its working ?
#define watch(x) cout << (#x) << " is " << (x) << endl;
int t = 90;
watch(t);
// output is
t is 90
"stringizing" operator (#) converts macro parameters to string literals without expanding the parameter definition. It is used only with macros that take arguments.