好的,如果我在C++头函数中执行此操作:
#include <iostream>
#include <string>
using namespace std;
// Prerequisites ^
int main(){
int io_print([Here's what I need help with]){};
};
Run Code Online (Sandbox Code Playgroud)
我知道代码示例完全是语法错误,但我需要帮助的是尝试使用允许整数,浮点数和字符串的类型.所以我可以简单地做io_print(40)和io_print("Hi").我试过这个,根本找不到允许这种类型的任何类型,如果有任何机会知道答案,那么请回复.
我正在这样做,因为我想重新定义功能.请不要问为什么.
template <typename T>
void io_print(const T& x) {
cout << x;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
337 次 |
| 最近记录: |