Export part of the class namespace

I have a class that includes enum:

class appearance{
  // ... stuff ...
  enum color {BLUE, RED, GREEN};
};

I would like to add part of the namespace (c using) so that I can refer to the value BLUEsimply as BLUE, rather than appearance::BLUE. At the same time, I would like to keep enumwithin class{}, as I believe that this is most natural. I tried various combinations namespaceand using, but to no avail.

Any suggestions???

+5
source share
3 answers

, . AFAIK, using appearance::color , .

A :

  • A

  • , A

  • , A

+3

, . , - - enum , , .

EDIT: ++? , , ( -) .

+1

, , , enum .

namespace enums{
        enum color
        {BLUE
        ,RED
        ,GREEN};
} // namespace enums


using namespace enums;
class Foo
{
    int Bar(){return BLUE;}
}

- ...

+1

All Articles