author | klao |
Sun, 09 Jan 2005 20:06:57 +0000 | |
changeset 1063 | d53a12d49262 |
permissions | -rw-r--r-- |
alpar@1052 | 1 |
struct TR |
alpar@1052 | 2 |
{ |
alpar@1052 | 3 |
int a; |
alpar@1052 | 4 |
int b; |
alpar@1052 | 5 |
int c; |
alpar@1052 | 6 |
}; |
alpar@1052 | 7 |
|
alpar@1052 | 8 |
template<class T> struct D : public T |
alpar@1052 | 9 |
{ |
alpar@1052 | 10 |
|
alpar@1052 | 11 |
D(const T &tt) : T(tt) {}; |
alpar@1052 | 12 |
|
alpar@1052 | 13 |
template<class X> struct TA : public T { |
alpar@1052 | 14 |
X a; |
alpar@1052 | 15 |
TA(const T &t,const X& x) : T(t), a(x) {}; |
alpar@1052 | 16 |
}; |
alpar@1052 | 17 |
|
alpar@1052 | 18 |
template<class X> D<TA<X> > setA(const X &x) { |
alpar@1052 | 19 |
return D<TA<X> >(TA<X>(*this,x)); |
alpar@1052 | 20 |
} |
alpar@1052 | 21 |
|
alpar@1052 | 22 |
template<class X> struct TB : public T { |
alpar@1052 | 23 |
X b; |
alpar@1052 | 24 |
TB(const T &t,const X& x) : T(t), b(x) {}; |
alpar@1052 | 25 |
}; |
alpar@1052 | 26 |
|
alpar@1052 | 27 |
template<class X> D<TB<X> > setB(const X &x) { |
alpar@1052 | 28 |
return D<TB<X> >(TB<X>(*this,x)); |
alpar@1052 | 29 |
} |
alpar@1052 | 30 |
|
alpar@1052 | 31 |
template<class X> struct TC : public T { |
alpar@1052 | 32 |
X c; |
alpar@1052 | 33 |
TC(const T &t,const X& x) : T(t), c(x) {}; |
alpar@1052 | 34 |
}; |
alpar@1052 | 35 |
|
alpar@1052 | 36 |
template<class X> D<TC<X> > setC(const X &x) { |
alpar@1052 | 37 |
return D<TC<X> >(TC<X>(*this,x)); |
alpar@1052 | 38 |
} |
alpar@1052 | 39 |
~D() |
alpar@1052 | 40 |
{ |
alpar@1052 | 41 |
//Itt csinalunk valamit |
alpar@1052 | 42 |
} |
alpar@1052 | 43 |
}; |
alpar@1052 | 44 |
|
alpar@1052 | 45 |
D<TR> d() |
alpar@1052 | 46 |
{ |
alpar@1052 | 47 |
return D<TR>(TR()); |
alpar@1052 | 48 |
} |
alpar@1052 | 49 |
|
alpar@1052 | 50 |
int main() |
alpar@1052 | 51 |
{ |
alpar@1052 | 52 |
d(); |
alpar@1052 | 53 |
d().setA(5.5).setB(10).setC(1.5e12); |
alpar@1052 | 54 |
} |