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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:14:33+00:00 2026-06-07T02:14:33+00:00

Simple question, I just want to initialize a map to be empty, instead of

  • 0

Simple question, I just want to initialize a map to be empty, instead of being a nullptr.

 const std::map<std::string, std::string>* emptyDictionary;

I tried

const std::map<std::string, std::string>* emptyDictionary = {"", ""};

but obviously that’s not right.
Thanks guys.

  • 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-07T02:14:37+00:00Added an answer on June 7, 2026 at 2:14 am

    You forgot to make any map at all — you just made a pointer! You can make the pointer point to a dynamically allocated map:

     const std::map<std::string, std::string>* emptyDictionary
         = new std::map<std::string, std::string>;
    

    This map will be truly empty. If you add the initializer {{"", ""}}, which you may well do, then you don’t actually have an empty map, but rather a map with one element which maps an empty string to an empty string.

    Note that you can never modify your map through the const pointer, so it’s a bit questionable why you’d want to do this.

    Note also that wanton dynamic allocation is generally a poor programming style. There’s almost surely a better way to do whatever you need to do, or, based on your comment, you’re just grossly mis­under­stand­ing something: The best way to obtain a pointer is to take the address of an existing object:

    std::map<std::string, std::string> m;
    foo(&m); // pass address of m as a pointer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question, I just want to select the text from the <Template> tag. Here's
Probably very simple question (I just want to ensure I'm right). Title is not
Asking a simple question, just want everyone have fun to solve it. I got
Real simple question (so I thought), I just want to send mail from my
Just a simple question, just as the title states. I just want to know
I have a really simple question, but I just want to know what the
I just want to ask a simple question related the GLSurfaceView and drawn objects
Simple question, hopefully an easy way and just want to verify I'm doing it
Ok relatively simple question here. I just want to display the autosaves/revisions on my
This is a super simple question that I just can't seem to find a

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.