Forward declaration of a nested class

J

Jiri Palecek

Hi
How can I (can I?) forward declare a nested class without having
to define the class it is nested in? Like this

class A;
class A::B;
void f(A::B*);

Thanks in advance

Jiri Palecek
japeleck at web dot de
 
J

Jonathan Turkanis

Jiri Palecek said:
Hi
How can I (can I?) forward declare a nested class without having
to define the class it is nested in? Like this

class A;
class A::B;
void f(A::B*);

Thanks in advance

One possible workaround is to define f to be a template

template<typename T>
void f(T*);

where f only relies on properties of T which A::B is known to satisfy.
If f(A::B) must coexist with other overloads of f(), you might be able
to use boost::enable_if.

Jonathan
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top