Re: newb question: need help with homework assignment
From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 05/29/04
- Next message: Elias Fotinis: "Re: A newbie question"
- Previous message: B. v Ingen Schenau: "Re: forward declaration error"
- In reply to: Mike Wahler: "Re: newb question: need help with homework assignment"
- Next in thread: B. v Ingen Schenau: "Re: newb question: need help with homework assignment"
- Reply: B. v Ingen Schenau: "Re: newb question: need help with homework assignment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Elias Fotinis: "Re: A newbie question"
- Previous message: B. v Ingen Schenau: "Re: forward declaration error"
- In reply to: Mike Wahler: "Re: newb question: need help with homework assignment"
- Next in thread: B. v Ingen Schenau: "Re: newb question: need help with homework assignment"
- Reply: B. v Ingen Schenau: "Re: newb question: need help with homework assignment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]