Sign in to follow this  
ZQJ

Nested class forward declarations

Recommended Posts

ZQJ    496
Is it possible to do something like the following:
template<class A> class Foo {}

class Bar : public Foo<Bar::Baz>
{
public:
  class Baz {};
};

This doesn't seem like an unreasonable thing to do, but there doesn't seem to be any way of doing it. Of course I could move Baz into global scope (which is what I'm about to do), but I'm curious if there is a way of doing this or a good reason why it can't be done.

Share this post


Link to post
Share on other sites
Kalazart    148
There is something that get's close to that:


template <class Type>
class A
{ };

class B_aux
{
public:
class C { };
};

class B : public B_aux, public A<B_aux::C>
{ };




I mean... if you need class C to be private, I don't know how. Besides, this method is basically the same as declaring class C as global.

Share this post


Link to post
Share on other sites

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