This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
operator overloading
- To: gcc at gcc dot gnu dot org
- Subject: operator overloading
- From: "Peter J. Viitasaari" <pjviitas at flash dot lakeheadu dot ca>
- Date: Tue, 28 Nov 2000 18:12:30 -0500
Hello Everyone:
My first time here.
I am having a problems overloading an operator using class templates.
It goes something like this:
template<class T>
class Foo{
public:
Foo( int );
Foo<T> & operator=( Foo<T> & )
private:
int bar;
};
...
...
...
template<class T>
Foo<T> & Foo<T>::operator=( Foo<T> &t )
{
...
...
...
just testing here
cout << t.bar;
returm *t
}
This works fine if the right parameter is the same time as "this".
However, it bombs if the input paramter is a different type than T.
I hope someone can illuminate me on this problem.
Peter
--
Peter J. Viitasaari
Current Address:
#214A 413 Edward Street North
Thunder Bay ON P7C 4P6
Telephone: 807-473-3567
E-mail: pjviitas@flash.lakeheadu.ca
Alternate Address:
#301 245A Bay Street
Thunder Bay ON P7B 6P2
Telephone: 807-476-6304
E-mail: pjviitasaari@netscape.net