I’m using a unordered map pointer because of C++/Cli on Visual Studio 2008 (Using Windows Forms Application), but I can’t assign a value to it, it throws an error, as my code example is showing
//...
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"; // The Error is in this line, this is the line 37
cout << this->Accounts["hello"];
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
//...
Error given:
Error 4 error C2107: illegal index, indirection not allowed
C:\Projects\Test\Login.h 37
I hope my code was clear enough so you can visualize it.
Thanks in advance.
Accountsis a pointer, you need to dereference it: