我想向前声明一个const变量without,使其具有外部链接。但是在我看来,这是不可能的,因为extern
关键字同时表示“这具有外部链接”和“这是一个变量声明,而不是定义”,并且我不能一无所获:] >
//// main.cpp: //// extern const char table[256]; // forward declaration. External linkage. // const char table[256]; // Error: table requires an initializer // static const char table[256]; // Same error // foo uses table so I need it forward declared: char foo() { // uses table } const char table[256] = {...}; // Actual definition
我的理解正确吗?有任何解决方法吗?
我想向前声明一个const变量而不给它外部链接。但是在我看来,这是不可能的,因为extern关键字同时表示“这具有外部...
首先,仅为类型定义前向声明。您可以输入