c++中使用cout创建DebugPrint函数的简单方法
Simple way of DebugPrint function creation with cout in c++
是否有一些简单的方法来创建DebugPrint函数,基于cout,它将接受cout支持的所有数据类型。
我试着
void DebugPrint(void * data)
{
cout<<data<<endl;
}
使用模板:
template<class T> inline void DebugPrint( const T& data )
{
cout << data << endl;
}
或宏:
#define DebugPrint( data ) cout << data << endl;
模板总是更可取的…(通常)必须避免使用宏。
相关文章:
- 关于简单C++函数(is_palindrome)的逻辑的问题
- 关于 c++ 函数中指针赋值的简单问题
- 从函数返回任意简单类型的数据
- 如何在没有函数的情况下编写此代码并使C++更简单?
- 用于在 C++ 中使用 while 循环查找下一个素数的简单函数
- 查找定义我的 C/C++ 函数/宏的文件比'grep'更简单的方法
- 处理简单 cpp 类构造函数中的错误
- 尝试创建包含简单方程的函数
- 简单函数并不总是返回预期的输出
- 有没有一种简单的方法可以在对象向量上调用构造函数?
- 有没有一种简单的方法来调用带有默认参数的函数?
- "std::function"的简单版本:函数对象的生存期?
- C++简单函数困境
- Qt的新信号/时隙语法问题 - 连接到一个简单的函数
- 为具有多个参数的函数创建 SWIG 类型图的更简单方法?
- 这个简单的 C++ 递归函数来反转字符串有什么问题?
- 返回值的简单模板类成员函数专用化
- 在简单地移动参数时使用函数模板参数的优点
- 迭代器和简单的赋值/析构函数
- 如何使用这个 C++ 模板函数.简单的初学者问题