C++我是否错误地使用了void函数?

Bra*_*-NB 2 c++ function void

错误:

  • C2182:'tellStats':非法使用'void'类型
  • C2440:'初始化':无法从'std :: string'转换为'int'
  • 不允许不完整的类型.

所有这些错误都可以在这一行找到:

    //ClassPractice.cpp
    void tellStats(pick);
Run Code Online (Sandbox Code Playgroud)

哪个叫......

    //Functions.h
    void tellStats(string);
Run Code Online (Sandbox Code Playgroud)

这被定义为......

    //Functions.cpp
        void tellStats(string choice)
    {
        if (choice == "wizard")
            {
            cout << "These are the Wizard's stats:" << endl;
            cout << "Max HP: 80\nSpeed: 7\nAttack: 10" << endl;
            }
    }
Run Code Online (Sandbox Code Playgroud)

我不明白为什么我会收到这些错误.我不知道为什么int甚至涉及错误.在这些代码部分中,我没有看到任何涉及int的内容.我以为我正确使用'void'因为我不想用函数返回值.

mar*_*rsh 6

你不要用返回类型调用函数.不要说:

void tellStats(pick);
Run Code Online (Sandbox Code Playgroud)

只是用tellStats(pick);.

那条线路是你调用tellStats的唯一地方吗?