Hi all,

I must be blind or stupid. Please consider the following code:

----

....

template <class T> class P;

template <class T> P<T> operator*(T,const P<T>&);

template <class T>

class P{

private:

T d;

public:

P(int i=0);

P<T> operator*(T);

friend P<T> operator*<>(T,const P<T>&); // this is line 15

};

template <class T> P<T> operator*(T x,const P<T>& p)

{

return P<T>(x*p.d);

}

template <class T>

P<T>:

(int i) : d(i) {}

template <class T>

P<T> P<T>:

perator*(T x)

{

return P<T>(x*d);

}

int main()

{

P<int> p(4),q,r;

q=3*p;

r=p*3;

return 0;

}

----

Compiling this code, e.g. g++ 4.0 says:

opp.cc:15: error: declaration of 'operator*' as non-function

opp.cc:15: error: expected ';' before '<' token

Intel 9.0 says:

opp.cc(15): error: function "P<T>:

perator* [with T=int]" is not a

template

friend P<T> operator*<>(T,const P<T>&);

Mysteriously, when I interchange the friend declaration in P

with the declaration of the member operator*, everything

is fine. What's going on?

Thanks for any help,

bye,

Georg.