static const vs. const static

后端 未结 4 1014
一整个雨季
一整个雨季 2020-12-23 17:15

I do not understand the difference between these two statements in my C++ class:

class MyClass {
  public:
  private:
     static const int var = 0;                   


        
4条回答
  •  半阙折子戏
    2020-12-23 18:03

    They are the same. But I would always go for Option 1 for a simple reason that the keywords const and int fit better when juxtaposed as they define the datatype. Where as the keyword static defines the accessibility of that variable.

提交回复
热议问题