Forward declaration of a nested class

Discussion in 'C++' started by Jiri Palecek, Jul 26, 2004.

  1. Jiri Palecek

    Jiri Palecek Guest

    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
    Jiri Palecek, Jul 26, 2004
    #1
    1. Advertising

  2. 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.
    Victor Bazarov, Jul 26, 2004
    #2
    1. Advertising

  3. "Jiri Palecek" <> wrote in message
    news:...
    > 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
    Jonathan Turkanis, Jul 26, 2004
    #3
    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. E11
    Replies:
    1
    Views:
    4,742
    Thomas Weidenfeller
    Oct 12, 2005
  2. qazmlp
    Replies:
    1
    Views:
    595
    Jonathan Turkanis
    Feb 15, 2004
  3. Stephane Routelous
    Replies:
    5
    Views:
    17,089
    Gianni Mariani
    Feb 19, 2004
  4. Susan Baker
    Replies:
    1
    Views:
    376
    Victor Bazarov
    Jul 7, 2005
  5. Replies:
    2
    Views:
    435
    Marcus Kwok
    Feb 28, 2007
Loading...

Share This Page