So here are my classes:
class A
{
public:
static MyObject *getObject(std::string string)
{
if(string == "string1")
return object1;
else if(string == "string2");
return object2;
else
return object3;
}
static MyObject *object1;
static MyObject *object2;
static MyObject *object3;
}
#include "A.h"
class B
{
public:
void initMethod();
void myMethod();
}
//B.cpp file
#include "B.h"
void B::init()
{
A::object1 = new MyObject();
A::object2 = new MyObject();
A::object3 = new MyObject();
}
void B::myMethod
{
MyObject *currentObject = A::getObject("string1");
//Do stuff with MyObject
}
As you can see, I am first trying to initialize the members of A inside of B and then access those members later on in a different function. However, any time I try to access the A class data inside B, I get an "undefined symbol for architecture x86_64" compiler error and I can't seem to figure out why. What am I doing wrong?