Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:47:40+00:00 2026-06-01T05:47:40+00:00

unordered_map<std::string, std::string>* Accounts; I have this code up there to initialize from a pointer,

  • 0
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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:47:42+00:00Added an answer on June 1, 2026 at 5:47 am
    unordered_map<std::string, std::string>* Accounts = new unordered_map<std::string, std::string>();
    

    Just remember you need to delete it when you are done.

    delete Accounts;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

unordered_map<std::string,unordered_map<std::string, std::string> >* storing_vars; I have this variable in the scope declared in the
I have the following code: #include <string> #include <iostream> #include <tr1/unordered_map> typedef std::tr1::unordered_map<unsigned long
I Have a object which the following field : boost::unordered_map<std::string, std::shared_ptr<Foo> > m_liste_; I
Yesterday i tried to use std::unordered_map and this code confused me how much memory
I have the following code: #include <iostream> #include boost/unordered_map.hpp using namespace std; using namespace
Consider the following code: #include <unordered_map> struct A {}; struct T { std::unordered_map<std::string, A>
I've been switching my code over from std::map to std::unordered_map where appropriate. With std::map
suppose i have the following: boost::unordered_map< string , someValueType > map; someValueType& value =
class MyObject{ public: void testFunctionMap(){ std::unordered_map<std::string, std::function<void()> > functionMap; std::pair<std::string, std::function<void()> > myPair(print, std::bind(&MyObject::printSomeText,
I am trying to do the following: boost::unordered_map<boost::flyweight<std::string>, boost::flyweight<std::string> > map; boost::flyweight<std::string> foo(name); map[foo]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.