Defining constexpr static data members

前端 未结 3 747
广开言路
广开言路 2020-12-19 07:34

So, I\'m aware that in C++ static members can be initialized inside the class if they are a const literal type like the following

class test{
public:
               


        
3条回答
  •  醉酒成梦
    2020-12-19 08:09

    static constexpr int stc = 1; // declares the static var
    
    constexpr int test::stc; // defines the static var
    

    for more detailed explanation check link below

    http://www.learncpp.com/cpp-tutorial/811-static-member-variables/

提交回复
热议问题