の内部クラスの静的メンバを定義する:私は名前空間でプライベート静的メンバを持つクラスを持っている場合は別の名前空間
namespace A {
class T {
public:
//functions
private:
static bool a;
static unsigned int b;
そして、私は、次のような別のファイルにこのクラスのユニットテストをしています:
namespace {
bool A::T::a = false;
unsigned int A::T::b = 1;
/* tests declaring an instance of A...*/
私はクランからのエラーが表示されます。
error: cannot define or redeclare 'a' here because namespace '' does not enclose namespace 'T'
error: cannot define or redeclare 'b' here because namespace '' does not enclose namespace 'T'
私は静的なプライベートメンバーに関する他の答えと、クラスの宣言がどこにあるのかを宣言する必要性を見てきました。これは私がここでやっていると信じているものですが、エラーはまだ私を逃しています。
'namespace {'は匿名です。宣言としての定義は '名前空間A 'で提案されましたが、そこではできません。 –