I have a class named MyClass
declared as follows:
#pragma once
class Object_Class;
class MyClass
{
static Object_Class *object;
public:
static void setObject_Class(Object_Class *var);
};
object
is a private static variable that points to an object of class Object_Class
. In the implementation file, I am trying do this:
void MyClass::setObject_Class(Object_Class *var) {
object = var;
}
However, I am getting a symbol not found for i386 architecture error pointing to this assignment. What am I doing wrong, and how do I fix this? Is this the best way to pass object and store it in another class variable, or is there a better way?
You need to declare and initialize storage for static objects: