Default enum visibility in C++

Posted by Benjamin Borden on Stack Overflow See other posts from Stack Overflow or by Benjamin Borden
Published on 2011-02-17T15:16:03Z Indexed on 2011/02/17 15:25 UTC
Read the original article Hit count: 320

Filed under:
|
|

I have a class that looks like this:

namespace R 
{
class R_Class 
{
   enum R_Enum
   {
       R_val1,
       R_val2,
       R_val3
   }
private:
   // some private stuff
public: 
  // some public stuff
}
}

I'm performing unit testing using an automated test tool (LDRA). The compiler (GHS) claims that my test harness cannot access the type R::R_Class::R_Enum.

I have no trouble accessing the values within a similar class that is defined as such:

namespace S
{
class S_Class
{
public:
   enum S_Enum
   {
       S_val1,
       S_val2,
       S_val3
   }
}
private:
   // some private stuff
public: 
  // some public stuff
}

Do enums in C++ need to be given explicit visibility directives? If not given any, do they default to private? protected?

© Stack Overflow or respective owner

Related posts about c++

Related posts about enums