I know when a class derived from UObject,at the same time a UClass will be defined for represent the class. In the UClass,it has a property named ClassDefaultObject which is a static object of the class derived form UObject. But when dose the static Object created? This confused me very long.
In the ue4’s C++ gameplay programing frame,I found this static object is used in many ways.So who is responsible for creating this static object?
I try to write a C++ test code like this:
class A {
public:
A(int i = 10) :m(i){}
static A a;
~A(){}
int get()const
{
return m;
}
private:
int m;
};
A A::a = A();
In standard C++ code,this form is ok. So,I guess the ue4’s class static object may be also use this form.
Can someone offer me a clear explanation?