duongthaiha wrote:
> Hi sorry for a new bee question. I have the following code but there
> is something that i can not understand what does it do.
> 
> Can you please tell me what does "Point &operator=( Point p)" does?
>  
> I think that the a overwrite the = operator but should it return bool
> instead of Point??

Nope.  You want to return the 'this' pointer because then you can do:

Point TestPoint, TestPoint2;

TestPoint = TestPoint2 = Point(1.2, 3.5, 5.0, 1.6);



NOTE:  You aren't returning anything from the overloaded operator. 
_However_, you don't need to define a copy constructor nor an assignment 
operator for the class because you aren't messing with pointers (and 
even if you were, you could get around that by using smart pointers). 
The compiler will define that functionality automagically for you.

As an interesting side note, I haven't written a single copy 
constructor/assignment operator in the past 6 months.  Safe C++ pretty 
much eliminated the need for that sort of stuff.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* VerifyMyPC 2.5
Change tracking and management tool.
Reduce tech. support times from 2 hours to 5 minutes.

http://www.CubicleSoft.com/VerifyMyPC/

Reply via email to