0

I decided to try and code a basic program but i keep getting this eror:

/tmp/cczXwiYT.o: In function main': main.cpp:(.text+0xd8): undefined reference toutils::checkInputs(std::__cxx11::basic_string, std::allocator >, std::__cxx11::basic_string, std::allocator >)' collect2: error: ld returned 1 exit status

Im new to c++ (just saying)

I tried to change the type from void to int to boolean etc.

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 

Thanks for the help =)

Petereo
  • 9
  • 5

1 Answers1

0

Thank you everyone as said by PaulSanders "Typo: change void checkInputs... to void utils::checkInputs... in utils.cpp." It fixed my problem just fine =)

Petereo
  • 9
  • 5