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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:23:00+00:00 2026-05-20T10:23:00+00:00

The thing is, I am not (knowing trying to use any default constructor of

  • 0

The thing is, I am not (knowing trying to use any default constructor of beatle::beatle
the error:

1>  ecosystem.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\map(172): error C2512: 'beatle::beatle' : no appropriate default constructor available
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\map(165) : while compiling class template member function 'beatle &std::map<_Kty,_Ty>::operator [](int &&)'
1>          with
1>          [
1>              _Kty=tokenID,
1>              _Ty=beatle
1>          ]
1>          c:\users\zak\documents\visual studio 2010\projects\ascii_sivvure\ascii_sivvure\ecosystem.h(22) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
1>          with
1>          [
1>              _Kty=tokenID,
1>              _Ty=beatle
1>          ]

Code with non relevant things stripped:

header:

typedef std::map<tokenID,beatle>    Beatles;

class ecosystem
{
private:
line 22:    Beatles m_Beatles;
};

source:

ecosystem::ecosystem(): m_output( output() )
{
    Beatles m_Beatles;
}

void ecosystem::populate()
{
    if (m_isMatingSeason && ( random(0,1000) < rateMATING ) )
    {
        beatle babyBeatle = breed();
        m_Beatles[babyBeatle.getTokenID()] = babyBeatle;
        m_field.occupy(babyBeatle.getTokenID(), babyBeatle.getLocation() );
    }
}

I’ve been trying for hours using different combinations of trying to properly define/declare the maps. At one point intellisense starting saying it wanted pointers to object here:

m_Beatles[babyBeatle.getTokenID()] = babyBeatle;

and that led me down a sad path.

This is all happening after my first(and hopefully last) refactoring binge, its been over a week since I’ve been able to compile… I probably have 40 hours just trying to get it working again.

  • 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-20T10:23:00+00:00Added an answer on May 20, 2026 at 10:23 am

    std::map<>::operator[] requires a default constructor. This is because it first creates an entry in the map then does the operator= that you are calling.

    If you absolutely want to use an std::map but do not want to provide a default constructor (perhaps it is illogical for your case?) you can use:

    std::map<>::insert()

    To explicitly insert the object into the code. This makes things a bit more complicated then because look ups must also use find.

    I just noticed that Adam Rosenfield already posted this info in a comment but going ahead and leaving this as a separate answer.

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

Sidebar

Related Questions

I'm working on a small roguelike game, and for any object/thing that is not
I was trying to find the way for knowing if two files are the
Why is this thing not working? [Database(Name=Relationships_Test)] [Table(Name = Order)] public class Order {
I don't honestly know if such thing exists or not, but I tried to
I am learning Java, theres one thing I do not understand.. in the main
GLSL has a full C-style preprocessor. The only thing that does not work is
I'm not sure about one thing. There are two things in object oriented programming.
One thing that bothers me about nHibernate is that it is not 100% compile
First thing i want to say that it's not an easy question to explain,
it looks very basic thing but i could not figure it out. var email

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.