C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use enum from a different namespace?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
toton
Guest





PostPosted: Wed Aug 23, 2006 9:10 am    Post subject: How to use enum from a different namespace? Reply with 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,
#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





PostPosted: Wed Aug 23, 2006 9:10 am    Post subject: Re: How to use enum from a different namespace? Reply with quote



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 ?
Quote:
--
Ian Collins.
Back to top
Ian Collins
Guest





PostPosted: Wed Aug 23, 2006 9:10 am    Post subject: Re: How to use enum from a different namespace? Reply with quote



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





PostPosted: Wed Aug 23, 2006 9:10 am    Post subject: Re: How to use enum from a different namespace? Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.