1.#define debug(...) printf( __VA_ARGS__)
2.#define debug(...) std::cout<< __VA_ARGS__
显然,1 可以,2 编译时会出错。是否有可能将“std::cout”与可变参数一起使用?
这个宏有什么意义?
'debug' 宏用于打印调试代码的内容。
void test(const classtype1 &obj1,const classtype2 &obj2)
{
// rewrite operator<<
debug(obj1,obj2);
//if use printf, I must call tostring method(or something likes that) to
//series the object to string.
debug(obj1.tostring(),obj2.tostring());
...
}