Forward declaration and embedded classes

J

jerome.pouiller

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,
 
K

Kai-Uwe Bux

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
 
J

jerome.pouiller

Kai-Uwe Bux a écrit :
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.
 
S

Sylvester Hesp

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
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top