Visual Studios C++代码中的错误。Lab4.obj : 错误 LNK2019: 未解析的外部符号"bool __cdecl



我正试图创建一个程序,对文件中的所有整数进行计数,并检查它们是否为偶数。我不断地把这个错误和"检查它们是否均匀"部分联系起来。这是我的代码:

#include<iostream>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include <string>
using namespace std;
bool isNotEven(int&);
int main()
{
    ifstream myfile("input.txt");
    int numberTot = 0;
    int numberOdd = 0;
    int check = 1;
    string line;
    while(check != -1)
    {
        getline(myfile,line);
        check = stoi(line);
        if (check != -1)
            numberTot++;
        if (isNotEven(check) == true)
            numberOdd++;
    }
    cout << "There are " << numberTot << " numbers in this file." << endl;
    cout << "There are " << numberOdd << " odd numbers in this file." << endl;
    char x;
    cin >> x;
}
bool isNoteEven(int& x)
{
    if (x%2 == 0)
        return false;
    else
        return true;
}

我一直收到这个错误,我很困惑为什么它会出现

1>  Lab4.cpp
1>Lab4.obj : error LNK2019: unresolved external symbol "bool __cdecl isNotEven(int &)" (?isNotEven@@YA_NAAH@Z) referenced in function _main
1>C:UsersNickDesktopCS1Lab4DebugLab4.exe : fatal error LNK1120: 1 unresolved externals

您拼写错误的函数名称是isNoteEven而不是isNotEven。

相关内容

最新更新