私は次のコードを持っていますが、この設定では匿名の名前空間内のxにどのようにアクセスできますかわかりません。どのように教えてください?匿名の名前空間内の変数へのアクセス(C++)
#include <iostream>
int x = 10;
namespace
{
int x = 20;
}
int main(int x, char* y[])
{
{
int x = 30; // most recently defined
std::cout << x << std::endl; // 30, local
std::cout << ::x << std::endl; // 10, global
// how can I access the x inside the anonymous namespace?
}
return 0;
}
あなたがすることはできません。それをしないでください。 –
多くの感謝... !!! –
関連記事:http://stackoverflow.com/questions/9622874/unnamed-namespace-access-rules – NathanOliver