c++ - question about accessing static member
- Szabolcs Horvát (23/23) Sep 09 2004 Could someone help with the following question:
- Daniel James (6/20) Sep 09 2004 Unless I've missed something, you've found a bug. This works on g++ and
Could someone help with the following question: If the following example compiles without errors, why doesn't it work when I make the member B::a static? (It works with Borland C++) This one compiles without error: template<class T> struct A { T t; }; class B { private: struct C { int i; }; A<C> a; public: B() { a.t.i = 0; } } Error: member 'B::C' of class 'B' is not accessible template<class T> struct A { T t; }; class B { private: struct C { int i; }; static A<C> a; // member a made static public: B() { a.t.i = 0; } } A<B::C> B::a; Sorry for my poor English.
Sep 09 2004
Szabolcs Horvát wrote:Error: member 'B::C' of class 'B' is not accessible template<class T> struct A { T t; }; class B { private: struct C { int i; }; static A<C> a; // member a made static public: B() { a.t.i = 0; } } A<B::C> B::a;Unless I've missed something, you've found a bug. This works on g++ and intel linux, provided you add the required semi-colon after your class definition.Sorry for my poor English.No need to apologise, it looks fine to me. Daniel
Sep 09 2004