我有以下代码 -
void CommandProcessor::ReplacePortTag((void *) portID)
{
std::string temp = std::string.empty();
int start = 0;
for (int i=0; i<CommandProcessor::fileContents.length(); i++)
{
if (CommandProcessor::fileContents.substr(i,6) == "<port>")
{
temp += CommandProcessor::fileContents.substr(start,i-start);
temp += portID;
start = i+6;
}
}
temp += CommandProcessor::fileContents.substr(start+6,CommandProcessor::fileContents.length()-start-6);
CommandProcessor::fileContents = temp;
}
当我尝试编译时我得到了错误 -
error C2448: 'CommandProcessor::ReplacePortTag' : function-style initializer appears to be a function definition
我无法弄清楚我哪里出错了。我该修改什么来修复此错误?
答案 0 :(得分:5)
此语法表示您是C样式将变量portID
转换为void*
void CommandProcessor::ReplacePortTag((void *) portID)
如果参数应该是void*
,那么你的函数声明应该是
void CommandProcessor::ReplacePortTag(void* portID)