0

Why does VS2017 C++ compiler report error C2864: a static data member with an in-class initializer must have non-volatile const integral type or be specified as 'inline' for the below? Is there anyway to initialize within the class instead of having to put it in the .cpp module? Even better, be able to initialize with [] instead of [3]?

class CTest
{
public:

  static const uint32_t Val1=1;
  static const uint32_t Val2=2;
  static const uint32_t Val3=3;

  struct sTestStruct
  {
    const uint32_t Val;
    const TCHAR *String;
  };

  static const sTestStruct s_arrMyValToString[3]={
    { Val1, _T("A Str") },
    { Val2, _T("B Str") },
    { Val3, _T("C Str") }
  };

};

TIA!!

user3161924
  • 1,849
  • 18
  • 33

0 Answers0