 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
toton Guest
|
Posted: Wed Aug 23, 2006 9:10 am Post subject: How to use enum from a different namespace? |
|
|
I have an enum in a namespace like,
namespace client{
namespace ui{
enum InkEnum{
ID_INK_COLOR,
ID_INK_WIDTH,
};
class InkEventHandler{
...
};
}
}
Now I want this enum in a different namespace,
#include "../client/ui/InkEventHandler.hpp"
using client::ui::InkEventHandler;
namespace ui{
class InkMenu : public ...{
/// I need the ID_INK_COLOR etc here inside the member function.
};
}
however using client::ui::InkEnum is not giving the desigred result.
ofcourse using namespace client::ui; is working, However it opens all
other definitions also, which I may not want.
Moreover I will use InkEnum with InkEventHandler only. Thus can I have
the enum inside the InkEventHandler class definition, so that whenever
I use the class ID_INK_COLOR etc are available?
thanks
abir |
|
| Back to top |
|
 |
toton Guest
|
Posted: Wed Aug 23, 2006 9:10 am Post subject: Re: How to use enum from a different namespace? |
|
|
Ian Collins wrote:
| Quote: | toton wrote:
I have an enum in a namespace like,
namespace client{
namespace ui{
enum InkEnum{
ID_INK_COLOR,
ID_INK_WIDTH,
};
class InkEventHandler{
...
};
}
}
Now I want this enum in a different namespace,
Just fully qualify it:
client::ui::InkEnum inkNum;
Where to write this line? inside namespace client::ui ? or in the |
InkMenu class definition file? All the enum variables are static
const? What the statement client::ui::InkEnum inkNum; means? They are
synonymous (reference) or copy ?
|
|
| Back to top |
|
 |
Ian Collins Guest
|
Posted: Wed Aug 23, 2006 9:10 am Post subject: Re: How to use enum from a different namespace? |
|
|
toton wrote:
| Quote: | I have an enum in a namespace like,
namespace client{
namespace ui{
enum InkEnum{
ID_INK_COLOR,
ID_INK_WIDTH,
};
class InkEventHandler{
...
};
}
}
Now I want this enum in a different namespace,
|
Just fully qualify it:
client::ui::InkEnum inkNum;
--
Ian Collins. |
|
| Back to top |
|
 |
Ian Collins Guest
|
Posted: Wed Aug 23, 2006 9:10 am Post subject: Re: How to use enum from a different namespace? |
|
|
toton wrote:
| Quote: | Ian Collins wrote:
toton wrote:
I have an enum in a namespace like,
namespace client{
namespace ui{
enum InkEnum{
ID_INK_COLOR,
ID_INK_WIDTH,
};
class InkEventHandler{
...
};
}
}
Now I want this enum in a different namespace,
Just fully qualify it:
client::ui::InkEnum inkNum;
Where to write this line? inside namespace client::ui ? or in the
InkMenu class definition file? All the enum variables are static
const? What the statement client::ui::InkEnum inkNum; means? They are
synonymous (reference) or copy ?
Use it anywhere you want a variable of type client::ui::InkEnum, from |
your original post, that would be as a member of InkMenu
Provided the appropriate header is included, you can use a fully
qualified name anywhere, just like you do whenever you use anything form
the standard library.
--
Ian Collins. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|