I would like to know the default value of variables inside a struct of static static std::unordered_map<std::string, struct>
.
Here's my example code:
#include <iostream>
#include <string>
#include <unordered_map>
int main()
{
enum MyStateType
{
MY_STATE_NEW,
MY_STATE_RUN,
MY_STATE_FREE
};
struct Foo
{
int num;
MyStateType state;
};
static std::unordered_map<std::string, Foo> map;
std::cout << map["Apple"].num << '\n';
std::cout << map["Apple"].state << '\n';
}
The output result:
0
0
Program ended with exit code: 0
Is it safe to think that variables inside Foo
are always initialized to 0
in the beginning?