2015-06-05 158 views
-4

我如何在C++中編寫它?PAWN到C++全局變量

// in PAWN (Procedural Language) 
enum e_player_data 
{ 
    id, // Integer 
    username[24] // string 
}; 
new PlayerData[50][e_player_data]; 
/* 
    so i can access it like PlayerData[1][id] = 1; or PlayerData[1][username] = "Firstname_Lastname"; 
*/ 

有人可以將它編碼爲C++嗎?

+0

[性病::地圖(http://www.cplusplus.com/reference/map/map/) – user463035818

回答

0

As tobi303在評論中寫道,您可以使用std :: map來完成此操作。

struct e_player_data 
{ 
    int id, 
    std::string username 
}; 
std::map<int,e_player_data> PlayerData; 

PlayerData[1].id = 1; 
PlayerData[2].username = "Firstname_Lastname"; 
+0

爲什麼'struct'和不是簡單的'std :: map '? – user463035818

1

您可以使用std::map

typedef std::map<int,std::string> Player; 

Player p; 
// add a player: 
int id = 0; 
p[id] = "Max Power";