Sign in to follow this  

Why doesn't this work? Templates (RESOLVED)

This topic is 4380 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
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

This topic is 4380 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this