unordered_map<std::string, std::string>* Accounts;
私はこのコードをポインタから初期化するために、ポインタ(*)を残しておけば、直接値を割り当てることができますが、問題は私がC++/Visual Studio 2008のCLIと、それは、このエラーがスローされますので、私はクラスのスコープシンプル:新しいunordered_map <std :: string、std :: string> *(ポインタ)をC++で初期化する方法は?
であり、変数を定義することはできません。
error C4368: cannot define 'Accounts' as a member of managed 'Test::Login': mixed types are not supported C:\ Projects\Test\Login.h 32
だから私は、私は、ポインタを行い、その後、それを初期化する必要があることを言われましたコンストラクタですが、どのようにポインタから作成するのですか? (私はAccounts = new unordered_mapのようなものだと思った) 私はいつも直接行く。
私は十分にはっきりしていたと思います。
@edit
public ref class Login: public System::Windows::Forms::Form
{
public:
unordered_map< std::string, std::string >* Accounts;
Test(void)
{
this->Accounts = new unordered_map<std::string, std::string>();
this->Accounts["hello"] = "test";
cout << this->Accounts["hello"];
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
それは、このエラーがスローされます。事前に
Error 4 error C2107: illegal index, indirection not allowed C:\Projects\Test Login.h 37
感謝を!
'Accounts = new unordered_map;'は機能しませんでしたか? –
Shahbaz
'新しいstd :: unordered_map()'? –
hmjd
@editを入れて、その中に値を設定しようとしたときにエラーが発生したことを知らせます。 – Grego