src/work/alpar/named-param-test2.cc
author alpar
Fri, 15 Apr 2005 19:56:25 +0000
changeset 1359 1581f961cfaa
permissions -rw-r--r--
Correct the english name of EGRES.
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
alpar@1052
     9
{
alpar@1052
    10
  T t;
alpar@1052
    11
  
alpar@1052
    12
  D(const T &tt) :t(tt) {};
alpar@1052
    13
  
alpar@1052
    14
  template<class X> struct TA : public T {
alpar@1052
    15
    X a;
alpar@1052
    16
    TA(const T &t,const X& x) : T(t), a(x) {};
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->t,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->t,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->t,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
}