BTW - With the values you have assigned those variables your "shortcut" condition will never be true.
I find macros to be helpful in situations like this. They can definitely be abused in evil ways but they can also be quite useful. Here's how I would do this :
using PCTSTR = const char *;
bool CompVarValues( PCTSTR varname, int value1, int value2 )
{
bool state = ( value1 == value2 );
PCTSTR boolstr = state ? "true" : "false";
std::cout << "comparing value of " << varname << " result is " << boolstr << std::endl;
}
#define CompareValues( a, b ) CompVarValues( #a, a, b )
CompareValues( my_name, a );
CompareValues( my_class, a );
CompareValues( my_age, a );