Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Forward declaration of a nested class

Reply
Thread Tools

Forward declaration of a nested class

 
 
Jiri Palecek
Guest
Posts: n/a
 
      07-26-2004
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-26-2004
Jiri Palecek wrote:
> How can I (can I?) forward declare a nested class without having
> to define the class it is nested in?


You cannot.
 
Reply With Quote
 
 
 
 
Jonathan Turkanis
Guest
Posts: n/a
 
      07-26-2004

"Jiri Palecek" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
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
nested class forward declaration n.torrey.pines@gmail.com C++ 2 02-28-2007 09:19 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Forward declaration and nested classes .. Susan Baker C++ 1 07-07-2005 01:25 PM
forward declaration of a structure nested in a class Stephane Routelous C++ 5 02-19-2004 09:41 PM
Re-forward declaration of types which were already forward declared qazmlp C++ 1 02-15-2004 07:00 PM



Advertisments