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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:03:41+00:00 2026-06-04T07:03:41+00:00

Foo.h : class Foo { public: Foo(void); ~Foo(void); void AddScreen(std::string name, ScreenBase &screenToAdd); private:

  • 0

Foo.h :

class Foo
{
public:
    Foo(void);
    ~Foo(void);   

    void AddScreen(std::string name, ScreenBase &screenToAdd);

private:

    std::map<std::string, ScreenBase> m_screens;
};

Foo.cpp :

void Foo::AddScreen(string name, ScreenBase &screenToAdd)
{
    m_screens[name] = screenToAdd; 
}

the last line creates a compile error C2784: ‘bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)’ : could not deduce template argument for ‘const std::

commenting out the last line and the compile succeeds.

I’m new to c++ (coming from a managed language) and don’t know why I can’t populate the map with this.

Any insight is appreciated. Thanks.

ScreenBase.h :

    #pragma once
    class ScreenBase
    {
    public:
        ScreenBase();
        ~ScreenBase();

        virtual void Update(float tt, float dt);
        virtual void Render();
    };

ScreenBase.cpp :

#include "pch.h"
#include "ScreenBase.h"

ScreenBase::ScreenBase(void)
{
}
ScreenBase::~ScreenBase(void)
{
}
void ScreenBase::Update(float tt, float dt)
{

}
void ScreenBase::Render()
{

}
  • 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-04T07:03:41+00:00Added an answer on June 4, 2026 at 7:03 am

    You forgot to add the following line to Foo.cpp

    #include <string>

    That should fix it.

    The reason that fixes it is because the “<” operator between 2 std::string objects is defined there. Since std::map is an associative array, it will sort the keys with either a specific sorting function you specify (as a third parameter for the template, e.g. std::map<int, MyObj, MyIntCompareFunctor>), or it will default to using < operator of the key type which in your case is std::string.

    P.S. Also, pass strings by reference, not value:
    e.g. void foo(const std::string& bar){};

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

Sidebar

Related Questions

class foo { public: void say_type_name() { std::cout << typeid(this).name() << std::endl; } };
I have a class like this public class foo { private void getThread() {
Consider this code: class Foo { public void doIt(String... strs) { System.out.println(this is varargs);
class Foo { String bar; // private String bar; } public class A {
Sample of code: public class Foo { public class Bar { public void printMesg(String
This is my Java 1.6 class: public class Foo { private ArrayList<String> names; public
class Foo { public: void bar(); }; void Foo::bar() { static int n =
Consider the following Java class: public class Foo { public static void doStuff() {
If I have the following code: public class Foo { public void Bar() {
Here is the code, it's pretty straightforward. class Foo { public: void print() {

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.