dependent name is not a type prefix with 'typename' to indicate a type???
-
Hallo,
ich hab unten mal meinen code etwas abstrahiert um das problem auf den punkt zu bringen, ich hab leider keine ahnung wo das problem liegt. vllt kann mir ja jemand helfen, wäre sehr dankbar.template<class t> class A { t a; public: A(t const &src = t()); class B { private: t b; public: B(t const &src = t()); B &operator = (B const &src); }; }; template<class t> A<t>::A(t const &src) { a = src; }; template<class t> A<t>::B::B(t const &src) { b = src; }; template<class t> //hier liegt der fehler beim rückgabetyp, //ich hab mal nur B, statt A<t>::B ausprobiert geht aber auch nicht A<t>::B &A<t>::B::operator = (B const &src) { b = src.b; return *this; };also meldung vom compiler (MSVC++2008EE) bekomme ich dann folgendes:
warning C4346: 'A<t>::B' : dependent name is not a type prefix with 'typename' to indicate a typevielen dank schon mal im voraus.
grüße
-
template<class t> typename A<t>::B &A<t>::B::operator = (B const &src) { b = src.b; return *this; };Du musst dem compiler sagen, dass A::B ein Typ ist. Es könnte ja auch ein statischer Member sein oder sowas. Andere Compiler geben hier denke ich sogar einen Fehler aus (was glaube ich auch so im standard steht)
-
ok danke, hat funktioniert.