Topic: BIG CHALLANGE
Author: akrause@TechFak.Uni-Bielefeld.DE (Andre Krause)
Date: 1995/05/05 Raw View
Hi !
If you can solve this problem, you are a really
expierienced programmer !!
look:
template<class T> class VEKTOR3D
{
protected:
public:
T x,y,z;
// ok thats a standard way. but if you want to assign
// VEKTOR3D<int> a with VEKTOR3D<float> b, the compiler
// says, that it cannot convert the types.
VEKTOR3D<T>& operator=(VEKTOR3D<T>&t){ x=t.x;y=t.y;z=t.z;return *this; }
// so I tried the following:
template<class TT> VEKTOR3D<T>& operator=(VEKTOR3D<TT>&t) { ....
// and he gives me an syntax error !!!!!
// even this dont work:
template<T,class TT> VEKTOR3D<T>& operator= .....
};
// and this is also not possible, because the compiler wants operator=
// to be a member function
template <class T,class TT> VEKTOR3D<T>&operator=(VEKTOR3D<T>&t,VEKTOR3D<TT>&tt) { ....
So, does the ANSI-Comitee missed something or is there another way to
solve this problem ??????
So, where are you, big C++ Wizards ??
If you wold be so kind, please send a mail to akrause@techfak.uni-bielefeld.de
Bye, Andre