David, Thanks, It's becoming a bit clearer.
Regards, Chip --- In [email protected], David <[EMAIL PROTECTED]> wrote: > > chipaug a écrit : > > Paul, > > Thanks for your help. Please see my comments embedded below. > > > > --- In [email protected], "Paul Herring" <pauljherring@> > > wrote: > > > >> On 5/30/07, chipaug <chipauger@> wrote: > >> > >>> In Chapter 0 of "Accelerated C++" the authors speak of results > >>> > > and side > > > >>> effects. I'm having some difficulty in distinguishing between > >>> > > them. > > > >> int i, j=5; > >> > >> i = printf("%d", j++); > >> > >> Result: i = 1 (number of characters printed) > >> Side effect: j = 6 (i.e. it's incremented) > >> > > > > Thanks. I was confused. I thought there would be two results, i = 1 > > and j = 6, and the character printed was the side effect. > > > > > > In Accelerated C++. 0.7 A slightly deeper look. > This is exclatly what they mean. > The side effect is the printing effect of the cout statement (else I > completly misunderstood english) > > "std::cout << "hello, world!" << std:: endl; > is an expression that, as its side effect, writes Hello, World! on the > standard output stream..." > > Paul answer, is in a technical point of view of the C++ or C language, > side effect is related > to sequence point (as I think - > http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40F_HTML/AQTLTB TE/DOCU_018.HTM > ) > > > In Accelerated C++, they speak about side effect as related to a > function result. > (http://www.edm2.com/0411/introc4.html) > > > http://en.wikipedia.org/wiki/Side_effect_%28computer_science%29 > In fact, it seems to this last definition that printf( "sdflk", j++ ) > has two side effects (printing and incrementing) > > > Hope it can helps. > Regards, > David >
