author | hegyi |
Fri, 04 Feb 2005 15:32:11 +0000 | |
changeset 1123 | a2e93889a604 |
child 1203 | 14f951664a63 |
permissions | -rw-r--r-- |
alpar@1105 | 1 |
class AlgorithmDefaultTypes |
alpar@1105 | 2 |
{ |
alpar@1105 | 3 |
public: |
alpar@1105 | 4 |
typedef int Adat; |
alpar@1105 | 5 |
}; |
alpar@1105 | 6 |
|
alpar@1105 | 7 |
template<class T = AlgorithmDefaultTypes> |
alpar@1105 | 8 |
class AlgorithmTypes : public T |
alpar@1105 | 9 |
{ |
alpar@1105 | 10 |
public: |
alpar@1105 | 11 |
template<class X> |
alpar@1105 | 12 |
class SetAdat : public T { X Adat; }; |
alpar@1105 | 13 |
}; |
alpar@1105 | 14 |
|
alpar@1105 | 15 |
template<class T = AlgorithmTypes<> > |
alpar@1105 | 16 |
class AlgorithmDefaultDataFields : public T |
alpar@1105 | 17 |
{ |
alpar@1105 | 18 |
protected: |
alpar@1105 | 19 |
typename T::Adat adat; |
alpar@1105 | 20 |
}; |
alpar@1105 | 21 |
|
alpar@1105 | 22 |
template<class T = AlgorithmDefaultDataFields<> > |
alpar@1105 | 23 |
class Algorithm : public T |
alpar@1105 | 24 |
{ |
alpar@1105 | 25 |
int _intAdat; |
alpar@1105 | 26 |
public: |
alpar@1105 | 27 |
Algorithm() {}; |
alpar@1105 | 28 |
Algorithm(const T &tt) : T(tt) {}; |
alpar@1105 | 29 |
|
alpar@1105 | 30 |
template<class X> class _SetAdat : public T { |
alpar@1105 | 31 |
protected: |
alpar@1105 | 32 |
X adat; |
alpar@1105 | 33 |
public: |
alpar@1105 | 34 |
_SetAdat() {}; //"Algorithm<>::_SetAdat<double> b;"-hez kell!!!! |
alpar@1105 | 35 |
// De az is rossz!!!!! |
alpar@1105 | 36 |
_SetAdat(const T &t,const X& x) : T(t), adat(x) {}; |
alpar@1105 | 37 |
}; |
alpar@1105 | 38 |
|
alpar@1105 | 39 |
template<class X> |
alpar@1105 | 40 |
Algorithm<_SetAdat<X> > setAdat(const X &x) { |
alpar@1105 | 41 |
return Algorithm<_SetAdat<X> >(_SetAdat<X>(*this,x)); |
alpar@1105 | 42 |
} |
alpar@1105 | 43 |
|
alpar@1105 | 44 |
Algorithm &setIntAdat(int i) {_intAdat=i;return *this;} |
alpar@1105 | 45 |
//vagy: |
alpar@1105 | 46 |
Algorithm &intAdat(int i) {_intAdat=i;return *this;} |
alpar@1105 | 47 |
|
alpar@1105 | 48 |
typename T::Adat run() |
alpar@1105 | 49 |
{ |
alpar@1105 | 50 |
//Itt csinalunk valamit |
alpar@1105 | 51 |
return typename T::Adat(); |
alpar@1105 | 52 |
} |
alpar@1105 | 53 |
~Algorithm() |
alpar@1105 | 54 |
{ |
alpar@1105 | 55 |
//Itt nem csinalunk semmit |
alpar@1105 | 56 |
} |
alpar@1105 | 57 |
}; |
alpar@1105 | 58 |
|
alpar@1105 | 59 |
Algorithm<> algorithm() |
alpar@1105 | 60 |
{ |
alpar@1105 | 61 |
return Algorithm<>(); |
alpar@1105 | 62 |
} |
alpar@1105 | 63 |
|
alpar@1105 | 64 |
int main() |
alpar@1105 | 65 |
{ |
alpar@1105 | 66 |
Algorithm<> a; |
alpar@1105 | 67 |
|
alpar@1105 | 68 |
Algorithm<>::_SetAdat<double> b; b=b;//Ez itt nem az, amit szeretnenk!!! |
alpar@1105 | 69 |
|
alpar@1105 | 70 |
Algorithm<>::SetAdat<double> c; c=c; //Ez itt nem az, amit szeretnenk!!! |
alpar@1105 | 71 |
|
alpar@1105 | 72 |
a.run(); |
alpar@1105 | 73 |
// b.run(); |
alpar@1105 | 74 |
// c.run(); |
alpar@1105 | 75 |
|
alpar@1105 | 76 |
algorithm().run(); |
alpar@1105 | 77 |
algorithm().setAdat(5.2).run(); |
alpar@1105 | 78 |
} |