On Fri, Oct 19, 2001 at 11:57:34AM +0100, Angus Leeming wrote: > > [And you can use a lot of forward declarations instead of including whole > > headers (especially true for enums)...] > > Tell me how! (PLEASE!) I've always been irritated by this. How do you deal > with: > > struct foo { > enum bar { ... }; > }; > > class foo2 { > func(foo::bar); > }; > > I've never worked out how to forward-declare foo::bar.
It's not possible. The point is, you can hide it if you are willing to pay for an extra indirection: Your problem: //////////////////////////////////////////////////////////////////// //--------- foo.h --------- // struct foo { enum bar { ... }; }; //--------- foo2.h --------- // #include "foo.h" // needed here, and consequently used in every file // that includes foo2.h, say baz.h class foo2 { func(foo::bar); }; //--------- foo2.C --------- // #include "foo2.h" foo2::func(foo::bar) {} //////////////////////////////////////////////////////////////////// Enum-hiding in action: //////////////////////////////////////////////////////////////////// //--------- foo.h --------- // struct foo { enum bar { ... }; }; struct foo_bar_wrap { foo::bar the_foo_bar; }; //--------- foo2.h --------- // //#include "foo.h" // not needed anymore! struct foo_bar_wrap; // this is sufficient class foo2 { func(foo_bar_wrap const &); // pay on indirection }; //--------- foo2.C --------- // #include "foo.h" #include "foo2.h" foo2::func(foo_bar_wrap const & w) { // use w.the_foo_bar } //////////////////////////////////////////////////////////////////// > Incidentally, and general point: it's Friday. Why all the smileys? Because I did not work on Wednesday it is the second working day of the current week, which makes today a Tuesday... Andre' -- André Pönitz .............................................. [EMAIL PROTECTED]