[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About a small C++ program.



On Sun, 14 May 2000, guy keren wrote:

> > Although I was able to compile it without warnings I do not understand:
> > 1) What is the meaning of the first (left most) const in
> > 	const Integer operator+(const Integer& rv) ... ?  
> 
> it means that the '+' operator returns an 'r' value, not an 'l' value
> (that is, you cannot assign into the integer it returns). look at
> stroustroup for more info, or better yet - don't use operator overloading
> when you can avoid that.

a) Methods returning a const have nothing to do with operator overloading
b) You can assign into a method delcared int foo() either. Only a
   reference is an lvalue. In fact, in this example, the const in
   unneeded.

--
Moshe Zadka <moshez@math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com


=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il