Jump to content
  • Advertisement
Sign in to follow this  
Shamino

Why doesn't this work? Templates (RESOLVED)

This topic is 4682 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm building my own resource management class with the help of some articles here on gamedev, this template works just fine when it is in his project, why doesn't it work in mine?
// convenience resource proxy template
template <class T> class ResourceProxy
{
private:

	ResourceManager::ResourceID id;

public:

    ResourceProxy(ResourceManager::ResourceID inId)
    {
        id = inId;
    }

    ResourceProxy(char* fileName, CacheType cacheType,
        LoadResources loadFunc, FreeResources freeFunc)
    {
        id = RegResource(fileName, cacheType, loadFunc, freeFunc);
    }

    ~ResourceProxy()
    {
    }

    T& operator*()
    {
        return(*((T*)PtrForId(id)));
    }

    T* operator->()
    {
        return((T*)PtrForId(id));
    } 

};


Here is the errors
--------------------Configuration: NeHeGL - Win32 Debug--------------------
Compiling...
Resource_Manager.cpp
c:\documents and settings\jonathan\desktop\renderengine\resource_manager.h(103) : error C2629: unexpected 'class ResourceProxy<T> ('
        c:\documents and settings\jonathan\desktop\renderengine\resource_manager.h(123) : see reference to class template instantiation 'ResourceProxy<T>' being compiled
c:\documents and settings\jonathan\desktop\renderengine\resource_manager.h(103) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
        c:\documents and settings\jonathan\desktop\renderengine\resource_manager.h(123) : see reference to class template instantiation 'ResourceProxy<T>' being compiled
Error executing cl.exe.

NeHeGL.exe - 2 error(s), 0 warning(s)
Apparently its not expecting a constructor?

Share this post


Link to post
Share on other sites
Advertisement
Possible problems: you could be missing type declarations that are confusing the compiler. You could have an error in the source code preceeding the template that make the compiler confused with respect to the template being compiled.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!