I'm relatively new to CPP, currently in my second class for it, and while I was trying to compile a lab for my class I keep getting this error. I thought it might have something to do with file path but that doesn't seem to the be the case, does anyone have any suggestions? Here is the code:
#include <iostream>
#include <string>
using namespace std;
class personType {
private:
string firstName;
string lastName;
public:
void setName (string, string) {
cin >> firstName;
cin >> lastName;
}
const string getFirstName() {
return firstName;
}
const string getLastName() {
return lastName;
}
void print() {
cout << firstName << ", " << lastName << endl;
}
personType(string = "", string = "");
};
int main() {
personType John;
John.setName("John", "Doe");
John.getFirstName();
John.getLastName();
John.print();
return 0;
}
Here is the compiler error message:
Undefined symbols for architecture x86_64: "personType::personType(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >)", referenced from: _main in CS200Lab1-022e17.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Build finished with error(s).