小编SAb*_*shi的帖子

为什么“int const B::bsm1a;” 不考虑重新定义吗?

#include <iostream>
struct B {
public:
    static int const bsm1a{ 0xf };
};
int const B::bsm1a; // 1) Why is this NOT considered a redefinition?
                    // 2) What does this line actually do here?

int main()
{
    std::cout << "Hello World!\n";
}
Run Code Online (Sandbox Code Playgroud)
#include <iostream>
struct B {
public:
    static int const bsm1a{ 0xf };
    static int const bsm1a; // Considered as a redefinition here and throws error C2086
};

int main()
{
    std::cout << "Hello World!\n";
}
Run Code Online (Sandbox Code Playgroud)

我的问题(嵌入在代码中):

  1. 为什么这不被视为重新定义?
  2. 这条线实际上在这里做什么?

c++ visual-studio

2
推荐指数
1
解决办法
419
查看次数

标签 统计

c++ ×1

visual-studio ×1