unordered_map<std::string, std::string>* Accounts;
I have this code up there to initialize from a pointer, I could just leave the pointer( * ) out of it and I could directly assign the value into it, but the problem is that I’m using C++/Cli on Visual Studio 2008 and I can’t define a variable there in the class scope
because it throws this error:
error C4368: cannot define ‘Accounts’ as a member of managed
‘Test::Login’: mixed types are not
supported C:\
Projects\Test\Login.h 32
So I was told that I should make a pointer and then initialize it in the constructor, but how do I create it from the pointer ? (I thought something like Accounts = new unordered_map)
I use to always go directly.
I hope I was clear enough.
@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
//
}
it throws this error:
Error 4 error C2107: illegal index, indirection not
allowed C:\Projects\Test
Login.h 37
Thanks in advance!
Just remember you need to delete it when you are done.