[英]default const char* template argument in a template template function
[英]const char[] default function argument
我已经定义了这样的类型:
typedef char sType[256];
和一个函数,默认参数:
void foo(const sType param = NULL);
MinGW(g ++ 4.8.0)编译它没有错误。
相反,Visual Studio 2015(工具14.0)给出以下错误:
error C2040: 'sType': 'int' differs in levels of indirection from 'char [256]'
我试图将NULL
为const char[]
,但这会导致:
error C2440: 'type cast': cannot convert from 'int' to 'const char []'
任何提示? 谢谢
不将NULL
为const char[]
(或sType
),而是转换为const char*
。 函数参数在声明中经历了数组到指针的衰减。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.