As the question states i'm trying to initalize a static class member variable using this same class's static member function but at a chosen time during runtime.
The is that the copy constructor for GameDataLocalResource is implicitly deleted because one of its fields has no copy assignement operator. So I tried to define the copy constructor but i'm still getting the same error at compilation.
How should i handle the problem. Please keep in mind i'm beginner in C++.
I looked at many thread on how to initialize a static member variable at runtime but none seems to fit my situation.
//*.h file
class GameDataResource
{
private:
static GameDataLocalResource local_resource;
public:
static void initializeLocalResource();
static GameDataLocalResource getLocalResource();
}
//*.cpp file
void GameDataResource::initializeLocalResources()
{
GameDataResource::local_resource = GameDataLocalResource();
}
GameDataLocalResource GameDataResource::getLocalResources()
{
return GameDataResource::local_resource;
}
//main.cpp
int main(int argc, char *argv[])
{
...
GameDataResource::initializeLocalResources();
qDebug() << GameDataResource::getLocalResources().getLoadingPercentage();
...
}
I expect to get the value of loading percentage but instead i get:
copy assignment operator of 'GameDataLocalResource' is implicitly deleted because field '****' has no copy assignment operator