www.digitalmars.com         C & C++   DMDScript  

c++.chat - Bug or No Bug ??? - test.cpp

The attached file is a small program that creates 2 classes.
all functions are defined inline.

The operator<< is overloaded to be able to sent to the object everything that
neeeds to be done.

The first class cTestIf has an if-statement in the operator<<(char *_txt)
the second class cTestNot has this if-statement in a shortened version

I was quite surprised seeing that both reacted differently :

the first :
I*IHello World!I*
I*IHello World!I*
I*IOne Step BeyondI*

the string only gets updated after the whole line is processed

the second
N*NHello World!N*
N*NOne Step BeyondN*
N*NStep TwoN*

the string is updated before the next operator<< is executed

Is this normal behaviour or is this a bug in how the 2 if-statements are treated
by dmc compiler/linker ?



Mens Sana In Corpore Sano
Oct 26 2004