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

  • Home
  • SEARCH
  • 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 963221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:38:25+00:00 2026-05-16T01:38:25+00:00

Could you let us know how to use stl:map as two dimension array? I

  • 0

Could you let us know how to use stl:map as two dimension array? I wanted to access the individual elements as like mymap[i][j] where I do not know beforehand what the value of i or j could be. Any better ideas to do the same thing in other way?

  • 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-05-16T01:38:25+00:00Added an answer on May 16, 2026 at 1:38 am

    You can do

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

    For example:

    #include <map>
    #include <iostream>
    
    int main() 
    {
        std::map<int, std::map<int, int> > mymap;
    
        mymap[9][2] = 7;
        std::cout << mymap[9][2] << std::endl;
    
        if (mymap.find(9) != mymap.end() && mymap[9].find(2) != mymap[9].end()) {
            std::cout << "My map contains a value for [9][2]" << std::endl;
        } else {
            std::cout << "My map does not contain a value for [9][2]" << std::endl;
        }
    
        return 0;
    }
    

    prints 7 on the standard output, followed by “My map contains a value for [9][2]”.

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

Sidebar

Related Questions

Could you let me know how can I change font size of button caption
Could anyone please let me know if there is a way to programatically determine
Could someone let me know whether boost thread library leaks. It seems to me
Could anyone let me know how to remove a class on an element using
Could you please let me know what is difference between DECLARE_DYNAMIC and DECLARE_DYNCREATE ?
could you please let me know about good IDEs available for javascript programming? I
I am searching for the exact counter $_SERVER['PHP_SELF']; which could let me know on
I show an image on the navigation bar (I use UIImageView). Could you let
hey guys was hoping you could help me out.. just to let u know
Let's say I have the following three strings: (section1){stuff could be any character, i

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.