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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:50:48+00:00 2026-05-16T06:50:48+00:00

I’ve been spoilt with C# coding the last few years and now I’m back

  • 0

I’ve been spoilt with C# coding the last few years and now I’m back onto C++ and finding that I’m having trouble with stuff that is supposed to be simple. I’m using a third party library for gamedev called DarkGDK (any commands which are prefixed with db), however DGDK isn’t the problem.

Heres my code:

System.h

#pragma once

#include <string>
#include <map>
#include "DarkGDK.h"

using namespace std;

class System
{
public:
    System();
    ~System();
    void Initialize();

    static void LoadImage(string fileName, string id);
    static int GetImage(string id);

private:
    map<string, int> m_images;
};

System.cpp

#include "System.h"

System::System()
{
}

System::~System()
{
}

void System::Initialize()
{
    dbSetDisplayMode (1024, 640, 32);
    dbSetWindowTitle ("the Laboratory");
    dbSetWindowPosition(100, 10);

    dbSyncOn         ();
    dbSyncRate       (60);

    dbRandomize(dbTimer());
}

void System::LoadImage(string fileName, string id)
{
    int i = 1;

    while (dbImageExist(i))
    {
        i++;
    }

    dbLoadImage(const_cast<char*>(fileName.c_str()), i, 1);
    m_images[id] = i;
}

int System::GetImage(string id)
{
    return m_images[id];
}

The idea here is to have a map which maps strings against integer values, to access images with a string instead of hardcoded values. This class isn’t done, so it doesn’t handle anything like unloading images. I want to access the image methods without passing an instance of System, so I used static.

Now I get this error:

blahblah\system.cpp(39) : error C2677:
binary ‘[‘ : no global operator found
which takes type ‘std::string’ (or
there is no acceptable conversion)

If I change the map to static, I get this linker error:

1>System.obj : error LNK2001:
unresolved external symbol “private:
static class std::map,class
std::allocator >,int,struct
std::less,class
std::allocator > >,class
std::allocator,class
std::allocator > const ,int> > >
System::m_images”
(?m_images@System@@0V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HU?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@@2@@std@@A)

Can any of you bright chaps help me out?

  • 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-16T06:50:49+00:00Added an answer on May 16, 2026 at 6:50 am

    The first one is a compiler error as you can not access the non-static data members from a static method. this pointer is not implictly passed to static methods hence they can not access data members bound to an instance.

    In the seconds case, note that static map<string,int> m_images; is just a declaration of a variable. You need to define the static member variable using map<string, int> System::m_images; in the source file. This will get rid of the linker error.

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

Sidebar

Related Questions

No related questions found

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.