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 8422605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:29:57+00:00 2026-06-10T03:29:57+00:00

I am trying to access a specific element out of a std::map with more

  • 0

I am trying to access a specific element out of a std::map with more than two elements. Here is an example:

std::map <int, CString, CString, CString> map;

//Initialise

map[0] = _T("stuff1"), _T("stuff2"), _T("stuff3");

//now if I just want to access stuff3 is it this:

CString str = map[0][2];

//or something more like this?

CString str = map[0]. ???

Any help would be great thanks.

edit: Thanks sorry about that, first time using maps, I was wondering why I couldn’t find any information on std::map ‘s with more elements inside.

  • 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-10T03:30:00+00:00Added an answer on June 10, 2026 at 3:30 am

    Have you tried to compile this? It shouldn’t.
    You can create only a map with exactly 1 key and 1 value for each element.

    But the value can be compound, so you can write

    struct ValueType {
     CString v1;
     CString v2;
     CString v3;
    }
    std::map <int, ValueType> map;
    

    and access elements like map[somekey].v3;

    To insert a value in such a map, you’ll have to write

    ValueType strings = {"1","2","3"};
    map.insert(999, strings);
    

    Or you may create a helper function (i.e. void addToMap(std::map <int, ValueType> &map, CSting const& v1, CString const& v2, CString const& v3) ), which will fill your map in a more convenient way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access a specific element of the Dom using XPath Here
I'm trying to create an access control system. Here's a stripped down example of
Trying to prevent access to a specific file, not any files with a certain
I am trying to check if I have write access to a specific key
I am trying to access an exchange server to read emails from a specific
I am trying to delete all specific key element in my linked list in
Basically I am trying to configure Access to a specific Folder on my shared
The specific area I'm trying to access is the body of the New Email
I'm trying to access the previously iterated element in a loop going through all
Trying to access a specific localised resource file such as WebResource.en.us which is located

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.