C++ 未定义对 `utils::checkInputs 的引用

C++ undefined reference to `utils::checkInputs

我决定尝试编写一个基本程序,但我不断收到此错误:

/tmp/cczXwiYT.o: 在函数 main': main.cpp:(.text+0xd8): undefined reference toutils::checkInputs(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator > )' collect2:错误:ld 返回了 1 个退出状态

我是 c++ 的新手(只是说)

我尝试将类型从 void 更改为 int 到 boolean 等

main.cpp

#include <iostream>
#include <string>
#include <fstream>
#include "utils.h"

int main(){

    utils u;

    std::string a = "a";
    std::string b = "a";
    u.checkInputs(a,b);

    return 0;
}

utils.cpp

#include <iostream>
#include <string>
#include <fstream>

#include "utils.h"

using namespace std;

utils::utils(){};

void checkInputs(string userInput, string target){
    cout << "hey i work" << endl;
}

utils.h

#ifndef UTILS_H
#define UTILS_H

    #include <iostream>
    #include <string>
    #include <fstream>

    using namespace std;

class utils
{
    public:
        utils();
        void checkInputs(string userInput, string target);
};

#endif 

感谢您的帮助=)

谢谢大家,正如 PaulSanders 所说 "Typo: change void checkInputs... to void utils::checkInputs... in utils.cpp." 它很好地解决了我的问题 =)