Hello all I keep getting a undefined reference for my string_to_int function and I have gone through it multiple times and can't seem to spot the reason it is throwing the error. Any help will be greatly apprechiated. Heres the full error:
main.cpp:(.text+0x20b): undefined reference to `string_to_int(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
main.cpp:(.text+0x2e9): undefined reference to `string_to_int(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status
It's unclear from how you posted your code, if lines 1-23 are in a separate file. And if so, what that file is named and if that file is a .h file, or a .cpp file.
From the error message, it would appear, that lines 1-23 are in a separate .cpp file, but that .cpp file did not get compiled and linked with main.cpp.
Thanks for the help AbstractionAnon, sorry for the confusion. Lines 2-11 are a file called utility.h, lines 15-23 are a file called utility.cpp, and the rest is the main file. How would I link the two .cpp files?
That depends on what compiler or IDE you're using.
Typically in an IDE you would have created a project, then added both main.cpp and utility.cpp to that project. The IDE should take care of compiling both and linking them together.