Re: newb question: need help with homework assignment

From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 05/29/04


Date: Sat, 29 May 2004 15:14:36 -0400 (EDT)


On Sat, 29 May 2004, Mike Wahler wrote:
>
> > template<class T>
> > T AddTwo(T x, T y)
> > {
> > T totalMinutes;
> > totalMinutes = x + y;
> > return (totalMinutes);

> 2. Note that the above can be simplified:
>
> return x + y;

  Just some pedantry: The two aren't entirely equivalent, are
they? I think the OP's code only works on types with an '='
operator defined, whereas your version doesn't need an '='
operator. (Which incidentally probably means your version is
"better" in general.)
  Your advice is good; I just want to see whether I'm not
missing anything about 'operator ='.

-Arthur