Declaration of a struct inside namespace

P

Paulo Matos

Hi all,

Imagine I have (with respective header guards):
foo.h :
namespace foo_ { struct foo {... }; };

Then I can:
bar.h:
#include "foo.h"

struct bar {
...
foo_::foo *xpto;
};

Well, but if I don't want to include foo.h and If foo was not inside
namespace foo_, I could just remove the include directive and replace
it by class foo;. However, since it is inside a namespace, is there to
do this to avoid header inclusion?

Regards,

Paulo Matos
 
R

Roland Pibinger

Imagine I have (with respective header guards):
foo.h :
namespace foo_ { struct foo {... }; };

Then I can:
bar.h:
#include "foo.h"

struct bar {
...
foo_::foo *xpto;
};

Well, but if I don't want to include foo.h and If foo was not inside
namespace foo_, I could just remove the include directive and replace
it by class foo;. However, since it is inside a namespace, is there to
do this to avoid header inclusion?

namespace foo_ { struct foo; };
struct bar {
...
foo_::foo *xpto;
};

Best wishes,
Roland Pibinger
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top