--- In [email protected], "Tamas Marki" <[EMAIL PROTECTED]> wrote: > > On 12/28/06, Nico Heinze <[EMAIL PROTECTED]> wrote: > > > > --- In [email protected], waqas ahmed <cooolwaqas1@> wrote: > > > > > > What is the output of printf("%d") > > > What will happen if I say delete this? > > > Why preincrement operator is faster than postincrement? > > > What will happen if I allocate memory using "new" and free > > > it using "free" or allocate sing "calloc" and free it > > > using "delete"? > > <snip> > > > > These few excerpts are IMO perfect examples of questions everyone > > should simply refuse to answer. Why? > > > > 1) printf( "%d") invokes undefined behaviour. > > 2) I'm no C++ expert, but I think "delete this;" is illegal. > > Victor, Paul, Thomas, et al., am I right? If so, this is > > another perfectly bad example. If not, thanks for explaining > > and please forgive me my lack of knowledge. > > In fact, it's legal to do so. Refer to: > http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.15 > > > 3) It's simply not true on most modern CPUs that a > > pre-increment works faster than a post-increment; the > > times when this was true is so long ago that it's not even > > worth recalling those times. This is an utterly useless > > question. > > > > Well, I might be wrong here, but in the context of objects > post increment can be slower than pre increment, because it > needs to return the old state of the object in a temporary.
Tamas, first thanks for the explanation about "delete this", second thanks for the correction about using a post-increment on objects. Yes, I have forgotten this application; you're right, in this case post-increment can be slower. Thanks. Regards, Nico
