What good are public variables then?

后端 未结 14 2308
悲哀的现实
悲哀的现实 2020-12-09 15:16

I\'m a total newbie with tons of ?\'s in my mind and a lot to experience with C++ yet! There\'s been something which I find really confusing and it\'s the use of public vari

14条回答
  •  渐次进展
    2020-12-09 15:32

    I know in Java we use public variables, in fact,

    public static final

    variables as means to specify constants before enumeration was introduced.

    For example,

    class Direction
    {
    
    public static final String NORTH = "north";
    ...
    }
    

    It has been a while I looked into C++, so not sure if there are enumerated types available. You can use the similar code above if enumeration is not available in C++

提交回复
热议问题