By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

Nested classes and templates

P: n/a
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::DCManag edTexture*>
{
public:
class DCManagedTexture : public DCResource, public DCMaterial
{}
};

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ni*********@web.de wrote:
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.
[...]

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.