Nested classes and templates

Discussion in 'C++' started by nitrogenycs@web.de, Apr 13, 2005.

  1. Guest

    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
    {}
    };
    , Apr 13, 2005
    #1
    1. Advertising

  2. 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.

    > [...]
    Victor Bazarov, Apr 13, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Razvan
    Replies:
    5
    Views:
    11,272
    Dale King
    Jul 27, 2004
  2. JKop
    Replies:
    3
    Views:
    449
  3. Replies:
    1
    Views:
    302
    Victor Bazarov
    Sep 6, 2005
  4. Replies:
    2
    Views:
    654
    mlimber
    Jun 9, 2006
  5. recover
    Replies:
    2
    Views:
    782
    recover
    Jul 25, 2006
Loading...

Share This Page