我如何用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 :(得分:1)
您可以使用std::map
:
typedef std::map<int,std::string> Player;
Player p;
// add a player:
int id = 0;
p[id] = "Max Power";
答案 1 :(得分:0)
正如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";