Nested classes and templates

N

nitrogenycs

Hello,

Code below.

I've run into the following problem. I want to pass DCManagedTexture*
as a template parameter into the DCDefaultResourceManager template. The
DCManagedTexture class is nested inside the DCTextureManager class. The
compiler (msvc 7.1)complains that it doesn't know anything about
DCTextureManager::DCManagedTexture* which is probably right. So I tried
to forward reference it (before the class declaration) with sth like:

class DCTextureManager;
class DCTextureManager::DCManagedTexture;

This does not work either. How can I pass the inner nested class as a
template parameter into the template parameter of the base class of the
enclosing class . Is this possible at all?
My alternative solution is to move the nested class outside of the
enclosing class, make it's contructors protected and declare it as a
friend in DCTextureManager to get the encapsulation I want. Does this
sound good or is there a better way?

Thanks for your answer!

-Matthias


Code:

class DCTextureManager : public
DCDefaultResourceManager<DCTextureManager::DCManagedTexture*>
{
public:
class DCManagedTexture : public DCResource, public DCMaterial
{}
};
 
V

Victor Bazarov

Code below.

I've run into the following problem. I want to pass DCManagedTexture*
as a template parameter into the DCDefaultResourceManager template. The
DCManagedTexture class is nested inside the DCTextureManager class. The
compiler (msvc 7.1)complains that it doesn't know anything about
DCTextureManager::DCManagedTexture* which is probably right. So I tried
to forward reference it (before the class declaration) with sth like:

class DCTextureManager;
class DCTextureManager::DCManagedTexture;

This does not work either. How can I pass the inner nested class as a
template parameter into the template parameter of the base class of the
enclosing class . Is this possible at all?
Nope.

My alternative solution is to move the nested class outside of the
enclosing class, make it's contructors protected and declare it as a
friend in DCTextureManager to get the encapsulation I want. Does this
sound good or is there a better way?
Yep.

[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top