This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

operator overloading


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]