2

I am on Ubuntu 12.04 using g++ as a compiler, and I've run into a problem trying to use the Alignment enums to place my GUI objects appropriately. Here is the relevant code from guichan's graphics.hpp:

...
00053 namespace gcn
00054 {
00055     class Color;
00056     class Font;
00057     class Image;
00058 
00094     class GCN_CORE_DECLSPEC Graphics
00095     {
00096     public:
00100         enum Alignment
00101         {
00102             LEFT = 0,
00103             CENTER,
00104             RIGHT
00105         };
...

Here is the line I am using to attempt to access the CENTER.

gcn::Graphics::Alignment _align = gcn::Graphics::Alignment::CENTER;

There error I receive is:

error: ‘gcn::Graphics::Alignment’ is not a class or namespace

I hope someone can give me a hand, I've searched everywhere for a similar problem, but to no avail.

2
  • 1
    gcn::Graphics.Alignment Commented Nov 10, 2013 at 0:33
  • Unfortunately that doesn't work, or at least the different ways I have tried it. Commented Nov 10, 2013 at 0:41

1 Answer 1

2

The enumeration names are injected into the enclosing namespace unless you use enum class which was introduced into C++ with the 2011 revision. If you use plain enum, you just qualify the names with enclosing scope:

gcn::Graphics::CENTER
Sign up to request clarification or add additional context in comments.

2 Comments

+1, Note: Declaring a different enumeration type (like enum Position { LEFT=1,...} using the same symbol(s) (LEFT in this case) is likewise not legal until the aforementioned feature of C++11 (enum class) of this answer.
Thank you so much, Dietmar! :D Edit: I'll bear that in mind, thank you Craig.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.