pingus-devel
[Top][All Lists]
Advanced

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

Re: Intentional code?


From: David Philippi
Subject: Re: Intentional code?
Date: Fri, 11 Oct 2002 21:59:11 +0200
User-agent: KMail/1.4.1

On Friday 11 October 2002 21:16, Neil Hotmail wrote:
> PingusBug&
> PingusBug::operator= (const PingusBug& old)
> {
>   if (this == &old);
>     return *this;

What's strange to you at this code? 
That's the normal check for self that should be in every copy constructor to 
prevent foo = foo from doing any harm. If such an assignment is executed it 
will always take needless time and it may be fatal in case of a pointer 
member:

delete pointer_member;
pointer_member = new type(*old.pointer_member);

If old is the same as this the code above won't work as intended unless your 
intention was to crash the program (and it's unreliable even then *g*).

Bye David





reply via email to

[Prev in Thread] Current Thread [Next in Thread]