I define the adc_cmd[9] variable as static const unsigned char in my ADC class under private. Since this is a constant, I thought I would just define it inside the class, but this does not work:
#pragma once class ADC{ private: static const unsigned char adc_cmd[9] = { 0x87, 0xC7, 0x97, 0xD7, 0xA7, 0xE7, 0xB7, 0xF7, 0x00 };
Error:
error: a brace-enclosed initializer is not allowed here before '{' token error: invalid in-class initialization of static data member of non-integral type 'const unsigned char [9]'
...
Therefore, I tried to infer a string from the class using static const unsigned char ADC::adc_cmd[9] = { 0x87, 0xC7, 0x97, 0xD7, 0xA7, 0xE7, 0xB7, 0xF7, 0x00 }; but this gave this error:
error: 'static' may not be used when defining (as opposed to declaring) a static data member error: 'const unsigned char ADC::adc_cmd [9]' is not a static member of 'class ADC'
Obviously, I am not saying this correctly. What is the correct way to declare this?
source share