I'm new to C++, so maybe I'm making a simple mistake and did not realize. I'm using XCode.
I have the simplest class ever. In my main, I create an instance of it. Fine. But when I call any method from this object, XCode throws it:
Undefined symbols for architecture x86_64:
"A::getOne()", referenced from: _main in main.o
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
My code:
//A.h:
class A {
public:
int getOne();
};
//A.cpp:
#include "A.h"
int A::getOne() {
return 1;
}
//main.cpp:
#include <iostream>
#include "A.h"
int main(int argc, const char * argv[]) {
A a; //create object of class A
a.getOne(); //call a method
return 0;
}