我正在尝试在构造函数的成员初始化列表中初始化 const 成员变量。
我收到以下错误:
error: declaration does not declare anything [-fpermissive]
const uint32_t LEDS
^
我的代码:
#include <unistd.h>
class BaseAddr {
public:
BaseAddr():
LEDS (0x41200000),
SW1 (0x41210000), // switch 1
SW2 (0x41220000), // switch 2
AXI_BRAM (0x40000000), // 128 registers
AXI_DUMMY (0x43c00000) // 16 registers, 4 lsb are connected with leds
{ /* nop */ }
virtual ~BaseAddr() {}
const uint32_t LEDS;
const uint32_t SW1;
const uint32_t SW2;
private:
const uint32_t AXI_BRAM;
const uint32_t AXI_DUMMY;
};
为什么会出现这个错误?
最佳答案
关于c++ - 初始化 const 类成员,错误 : declaration does not declare anything,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22404868/