C++ where to initialize static const

前端 未结 5 1173
走了就别回头了
走了就别回头了 2020-11-27 11:17

I have a class

class foo {
public:
   foo();
   foo( int );
private:
   static const string s;
};

Where is the best place to initialize the

5条回答
  •  失恋的感觉
    2020-11-27 11:41

    Only integral values (e.g., static const int ARRAYSIZE) are initialized in header file because they are usually used in class header to define something such as the size of an array. Non-integral values are initialized in implementation file.

提交回复
热议问题