当我尝试编译代码时,我一直收到此错误,但我似乎不明白为什么。
Undefined symbols for architecture x86_64:
"Location::Location()", referenced from:
_main in main-64d6fd.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我使用“ g ++ * main.cpp”来尝试对其进行编译,但是无论我做什么,都会遇到相同的错误。
#include <iostream>
#include "location-proj.h"
using namespace std;
int main() {
Location loc;
return 0;
}
#include <iostream>
using namespace std;
class Location {
public:
Location();
private:
int row, col;
unsigned int nextDirection; //Uses ENUM as input
};
#include "location-proj.h"
Location::Location() {
this->row = 0;
this->col = 0;
this->nextDirection = 0;
}