Accessing to enum values by '::' in C++

后端 未结 3 1251
情深已故
情深已故 2021-02-13 09:35

I have class like following:

class Car  
{  
public:  
    Car();  
    // Some functions and members and enums  
    enum Color
    {
              


        
3条回答
  •  悲&欢浪女
    2021-02-13 10:03

    Name the enum inside the nested class (as example one):

    class Car
    {
    public:
        struct Color
        {
            enum Type
            {
                Red,
                Blue,
                Black
            };
        };
    
        Color::Type getColor();
        void setColor(Color::Type);
    };
    

提交回复
热议问题