class AlgorithmDefaultTypes { public: typedef int Adat; }; template class AlgorithmTypes : public T { public: template class SetAdat : public T { X Adat; }; }; template > class AlgorithmDefaultDataFields : public T { protected: typename T::Adat adat; }; template > class Algorithm : public T { int _intAdat; public: Algorithm() {}; Algorithm(const T &tt) : T(tt) {}; template class _SetAdat : public T { protected: X adat; public: _SetAdat() {}; //"Algorithm<>::_SetAdat b;"-hez kell!!!! // De az is rossz!!!!! _SetAdat(const T &t,const X& x) : T(t), adat(x) {}; }; template Algorithm<_SetAdat > setAdat(const X &x) { return Algorithm<_SetAdat >(_SetAdat(*this,x)); } Algorithm &setIntAdat(int i) {_intAdat=i;return *this;} //vagy: Algorithm &intAdat(int i) {_intAdat=i;return *this;} typename T::Adat run() { //Itt csinalunk valamit return typename T::Adat(); } ~Algorithm() { //Itt nem csinalunk semmit } }; Algorithm<> algorithm() { return Algorithm<>(); } int main() { Algorithm<> a; Algorithm<>::_SetAdat b; b=b;//Ez itt nem az, amit szeretnenk!!! Algorithm<>::SetAdat c; c=c; //Ez itt nem az, amit szeretnenk!!! a.run(); // b.run(); // c.run(); algorithm().run(); algorithm().setAdat(5.2).run(); }