Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Nested classes and templates

Reply
Thread Tools

Nested classes and templates

 
 
nitrogenycs@web.de
Guest
Posts: n/a
 
      04-13-2005
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:CManagedTexture* which is probably right. So I tried
to forward reference it (before the class declaration) with sth like:

class DCTextureManager;
class DCTextureManager:CManagedTexture;

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:CManag edTexture*>
{
public:
class DCManagedTexture : public DCResource, public DCMaterial
{}
};

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      04-13-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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:CManagedTexture* which is probably right. So I tried
> to forward reference it (before the class declaration) with sth like:
>
> class DCTextureManager;
> class DCTextureManager:CManagedTexture;
>
> 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.

> [...]

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Declaring Template Classes that take Multiple Nested Templates as Parameters pagekb@gmail.com C++ 2 06-09-2006 08:05 PM
Templates, nested classes and static members allspamgoeshere3@hotmail.com C++ 1 09-06-2005 10:46 PM
What is the difference between nested classes and inner classes ? Razvan Java 5 07-27-2004 07:59 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM



Advertisments