Z
zl2k
I have a header file like this:
#include <map>
#include <set>
struct SET_CREATOR{
static std::set<std::string> CreateSet() {
std::set<std::string> string_set;
string_set.insert("ab");
return string_set;
}
};
static std::set<std::string> MY_STRING_SET(SET_CREATOR::CreateSet());
struct MAP_CREATOR{
static std::map<std::string, std::string> CreateMap() {
std::map<std::string, std::string> string_map;
std::cout<<*MY_STRING_SET.cbegin()<<std::endl; // segmentation
error here
return string_map;
}
};
static std::map<std::string, std::string>
MY_STRING_MAP(MAP_CREATOR::CreateMap());
My question is: how may I initialize MY_STRING_SET properly so that it
can be used by other struct in the same header file? Thanks for help.
zl2k
#include <map>
#include <set>
struct SET_CREATOR{
static std::set<std::string> CreateSet() {
std::set<std::string> string_set;
string_set.insert("ab");
return string_set;
}
};
static std::set<std::string> MY_STRING_SET(SET_CREATOR::CreateSet());
struct MAP_CREATOR{
static std::map<std::string, std::string> CreateMap() {
std::map<std::string, std::string> string_map;
std::cout<<*MY_STRING_SET.cbegin()<<std::endl; // segmentation
error here
return string_map;
}
};
static std::map<std::string, std::string>
MY_STRING_MAP(MAP_CREATOR::CreateMap());
My question is: how may I initialize MY_STRING_SET properly so that it
can be used by other struct in the same header file? Thanks for help.
zl2k