Bir std::map
doldurmaya çalışıyorum, ancak 2 derleyici hataları alıyorum ve nedenini bilmiyorum. std :: map - C++ tüm bildirimler için bir tür belirtici gerektirir
std::map<std::string, std::string> dirFull;
dirFull["no"] = "north";
dirFull["so"] = "south";
dirFull["ea"] = "east";
dirFull["we"] = "west";
dirFull["nw"] = "north-west";
dirFull["ne"] = "north-east";
dirFull["sw"] = "south-west";
dirFull["se"] = "south-east";
olanlar
hataları şunlardır: Ben de denedimerror: C++ requires a type specifier for all declarations
dirFull["no"] = "north";
^
error: size of array has non-integer type 'const char[3]'
dirFull["no"] = "north";
^~~~
bu:
std::map<std::string, std::string> dirFull = {
{"no", "north"}, {"so", "south"},
{"ea", "east"}, {"we", "west"},
{"ne", "north-east"}, {"nw", "north-west"},
{"se", "south-east"}, {"sw","south-west"} };
Bu hatanın tam bir farklı türü ile sonuçlanır:
error: non-aggregate type 'std::map<std::string, std::string>' (aka '...') cannot be initialized with an initializer list
std::map<std::string, std::string> dirFull = {
^ ~
@TonyD Ben using namespace std 'kullanıyorum eklemeyi unuttuğu;' – user5759490
Ardından, bu atlanmış albümü başka kritik bir şey var olasıdır. Lütfen asılsız ve kısaltılmamış kodu en az bir örnek olarak ekleyin. –