Re: [ROOT] root(cint) and template

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Thu May 10 2001 - 19:27:23 MEST


On Thu, 10 May 2001 17:07:03 +0200 (MET DST)
"Jacek M. Holeczek" <holeczek@us.edu.pl> wrote
concerning ": [ROOT] root(cint) and template":
> Hi,
> What's wrong in :
> 	class Complex<float>
> 	{
> 	public:
> 	  (...)
> 	  Complex& operator+= (const Complex& r) { return __gsl_doapl (this, r); }
> 	  (...)
> 	}
> that I keep getting :
> 	Syntax Error: Complex&operator+=(constComplex&r) FILE:FComplex.hxx LINE:44
> Thanks in advance,
> Jacek.
>

it should be 

  #include<iostream>

  template<class T> 
  class Complex
  {
  public:
    T c;
    Complex<T>& operator+=(Complex<T>& r) { c += r.c ; return *this; } 
  };

  int main() 
  {
    Complex<float> a, b;
   
    a.c = 10;
    b.c = 11;
    cout << "a: " << a.c << "b: " << b.c << endl;

    b += a;
    cout << "a: " << a.c << "b: " << b.c << endl;

    return 0;
  }

ANSI/ISO C++ is very specific on this point. You _must_ provide the
template parameter in methods, etc.  

How are the GSL wrappers coming along? 

Yours, 

Christian  -----------------------------------------------------------
Holm Christensen                             Phone:  (+45) 35 35 96 91 
  Sankt Hansgade 23, 1. th.                  Office: (+45) 353  25 305 
  DK-2200 Copenhagen N                       Web:    www.nbi.dk/~cholm    
  Denmark                                    Email:       cholm@nbi.dk



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:45 MET