Forward declaration and embedded classes

Discussion in 'C++' started by jerome.pouiller@gmail.com, Jan 22, 2007.

  1. Guest

    I'd like to do this:

    class foo: public bar::mho {
    public:
    class mho { };
    };

    class bar: public foo::mho {
    public:
    class mho { };
    }

    Someone have a solution to declare this?

    Thanks,

    --
    Jezz
     
    , Jan 22, 2007
    #1
    1. Advertising

  2. Kai-Uwe Bux Guest

    wrote:

    > I'd like to do this:
    >
    > class foo: public bar::mho {
    > public:
    > class mho { };
    > };
    >
    > class bar: public foo::mho {
    > public:
    > class mho { };
    > }
    >
    > Someone have a solution to declare this?


    Why do you insist on mho being a local class? What about:


    class foo_mho {};
    class bar_mho {};

    class foo : public bar_mho {
    public:

    typedef foo_mho mho;

    };

    class bar : public foo_mho {
    public:

    typedef bar_mho mho;

    };


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Jan 22, 2007
    #2
    1. Advertising

  3. Guest

    Kai-Uwe Bux a écrit :
    > wrote:
    >
    > > I'd like to do this:
    > >
    > > class foo: public bar::mho {
    > > public:
    > > class mho { };
    > > };
    > >
    > > class bar: public foo::mho {
    > > public:
    > > class mho { };
    > > }
    > >
    > > Someone have a solution to declare this?

    >
    > Why do you insist on mho being a local class? What about:
    >
    >
    > class foo_mho {};
    > class bar_mho {};
    >
    > class foo : public bar_mho {
    > public:
    >
    > typedef foo_mho mho;
    >
    > };
    >
    > class bar : public foo_mho {
    > public:
    >
    > typedef bar_mho mho;
    >
    > };

    Because I'd like to do something like:
    template<class T> T &f(typename T::mho &arg);

    And your solution works fine in this case :)
    Thanks.
     
    , Jan 22, 2007
    #3
  4. <> wrote in message
    news:...
    > Because I'd like to do something like:
    > template<class T> T &f(typename T::mho &arg);
    >
    > And your solution works fine in this case :)
    > Thanks.
    >


    Keep in mind the compiler would never be able to deduce the arguments when
    such a function is called without explicit template arguments, so Kai-Uwe's
    solution even works better in that respect :)

    - Sylvester
     
    Sylvester Hesp, Jan 22, 2007
    #4
    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. qazmlp
    Replies:
    1
    Views:
    603
    Jonathan Turkanis
    Feb 15, 2004
  2. Susan Baker
    Replies:
    1
    Views:
    378
    Victor Bazarov
    Jul 7, 2005
  3. Heiner
    Replies:
    8
    Views:
    375
  4. HappyHippy

    forward declaration of classes

    HappyHippy, Nov 23, 2005, in forum: C++
    Replies:
    1
    Views:
    387
    Victor Bazarov
    Nov 23, 2005
  5. Andrea Crotti

    Forward declaration of classes

    Andrea Crotti, Oct 27, 2010, in forum: C++
    Replies:
    10
    Views:
    478
    Balog Pal
    Nov 3, 2010
Loading...

Share This Page