错误C2448:函数式初始值设定项似乎是函数定义

use*_*272 4 c++ visual-studio-2005

我有以下代码 -

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;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译时,我收到了错误 -

error C2448: 'CommandProcessor::ReplacePortTag' : function-style initializer appears to be a function definition
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚我哪里出错了.我该修改什么来修复此错误?

Cor*_*mer 5

此语法意味着您将C变量转换portID为avoid*

void CommandProcessor::ReplacePortTag((void *) portID)
Run Code Online (Sandbox Code Playgroud)

如果参数应该是void*你的函数声明应该是

void CommandProcessor::ReplacePortTag(void* portID)
Run Code Online (Sandbox Code Playgroud)