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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:20:28+00:00 2026-06-04T20:20:28+00:00

EDIT: Thanks to you both! I’m currently creating a template resource manager class and

  • 0

EDIT: Thanks to you both!

I’m currently creating a template resource manager class and it doesn’t show any errors in the actual code, but when I compile i get hit with a few of these

error C2227: left of ‘->getHandle’ must point to class/struct/union/generic type

template <class T>
unsigned int ResourceManager<T>::add(string& name, string& path)
{
    T* resource = getResource(name, path);

    if (resource != nullptr)
    {
        resource->incrementCount();    // doesn't like 
        return resource->getHandle();  // these lines calling member functions
    }
    else
        unsigned int handle;
        bool freeHandle = false;

        if (!m_freeHandles.empty())
        {
            handle = m_freeHandles.top();
            m_freeHandles.pop();
            freeHandle = true;
        }
        else
        {
            handle = m_resourceList.size();
            freeHandle = false;
        }

        T* newResource = new T(handle, name, path);

        if (!freeHandle)
            m_resourceList.push_back(newResource);
        else
            m_resourceList[handle] = newResource;

        return newResource->getHandle();
    }
    return -1;
}

For each resource i’ve got a base class Resource which looks like

class Resource
{
public:

Resource(unsigned int handle, string& name, string& path);
Resource(string& name, string& path);
virtual ~Resource();
string getFileName() { return m_filename; }
void setFileName(string filename) { m_filename = filename; }
string getFilePath() { return m_filepath; }
void getFilePath(string filePath) { m_filepath = filePath; }
string getName() { return m_name; }
void getName(string name) { m_name = name; }
unsigned int getHandle() { return m_handle; }
void setHandle(unsigned int handle) { m_handle = handle; }
void incrementCount() { m_referenceCount++; }
void decrementCount() { m_referenceCount--; }
int getReferenceCount() { return m_referenceCount; }

protected:

string m_filename;
string m_filepath;
string m_name;
unsigned int m_handle;
int m_referenceCount;
};

and i’m deriving various resources from this which i use like…

// just an abbreviated example
class Model : public Resource
{ };

ResourceManager<Model*> modelResourceManager;
modelResourceManager.add("model.obj", "models/");

Is there something i’m missing here? I’ve included “Resource.h” in ResourceManager.h and i’ve even included the specific implementations eg “model.h” but i’m still getting this error.

It could be very trivial, and i’ve just been staring at this entirely too long but help would be greatly appreciated.

  • 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-04T20:20:29+00:00Added an answer on June 4, 2026 at 8:20 pm

    You’re instantiating modelResourceManager with the template argument set to Model*. That is, T will be Model* in your templated code, so resource and newResource (which are T*) will be Model** – that is, pointer-to-pointer-to-Model.

    So resource-> isn’t valid. (*resource)-> would be; or perhaps you meant to use Model as the template argument.

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

Sidebar

Related Questions

Please let me know if you have any idea about it. Thanks EDIT What
Edit: Thanks- I understand it a lot more now. Its very confusing when you
EDIT: Thanks guys, got it! appears that the explode() function was called from the
Why new()/delete() is slower than malloc()/free()? EDIT: Thanks for the answers so far. Please
EDIT: SOLVED Thanks Brooks. Your question led me to keep digging into if the
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
Please see bottom edit for where I am currently at, thank you. I have
EDIT: Thanks Kenny and everyone else who answered similarly. It really was a DOH
I would be interested in answers for both Linux and NT (or any other
EDIT: Thanks guys - perfect! I wish I could check more than one answer,

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.