class AlgorithmDefaultTypes 
{
public:
  typedef int Adat;
};

template<class T = AlgorithmDefaultTypes>
class AlgorithmTypes : public T 
{
public:
  template<class X>
  class SetAdat : public T { X Adat; };
};

template<class T = AlgorithmTypes<> >
class AlgorithmDefaultDataFields : public T
{
protected:
  typename T::Adat adat;
};

template<class T = AlgorithmDefaultDataFields<> >
class Algorithm : public T
{
  int _intAdat;
public:
  Algorithm() {};
  Algorithm(const T &tt) : T(tt) {};

  template<class X> class _SetAdat : public T {
    protected:
    X adat;
    public:
    _SetAdat() {}; //"Algorithm<>::_SetAdat<double> b;"-hez kell!!!!
                   // De az is rossz!!!!!
    _SetAdat(const T &t,const X& x) : T(t), adat(x) {};
  };
  
  template<class X>
  Algorithm<_SetAdat<X> > setAdat(const X &x) {
    return Algorithm<_SetAdat<X> >(_SetAdat<X>(*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<double> b; b=b;//Ez itt nem az, amit szeretnenk!!! 

  Algorithm<>::SetAdat<double> c; c=c; //Ez itt nem az, amit szeretnenk!!!

  a.run();
  //  b.run();
  //  c.run();
  
  algorithm().run();
  algorithm().setAdat(5.2).run();
}
