I have a struct that contains three lists and an integer as can be seen in the code below.
struct MainScreenState
{
std::list<char*> sessionId;
std::list<char*> opposingUser;
std::list<char*> currentMove;
int totalScore;
MainScreenState() {
totalScore = 0;
}
};
struct MainScreenState *state;
To initialise an int is possible using a constructor, but how do you initialise the list objects so that you avoid the compiler warning “warning C4700: uninitialized local variable ‘state'”.
std::listmembers are automatically initialized. The problem is with the variablestate, which is un-initialized.or (per request)
or prefer using automatic-storage variables or a smart pointer.