pre-post increament
-
Dear All, Very Good morning. I am facing some conceptual doubts in post increament and pre increament operators in for loop. Kindly follow the code below: for(int i=0;i<5;i++) { cout<French is the language of love, for everything else there is c++ ...(anonymous)
-
Dear All, Very Good morning. I am facing some conceptual doubts in post increament and pre increament operators in for loop. Kindly follow the code below: for(int i=0;i<5;i++) { cout<French is the language of love, for everything else there is c++ ...(anonymous)
For a built in type and not using the result of the expression
++n
; andn++;
do the same thing. The only time there are any differences in behaviour are when the operators are used in more complicated expressions e.g.:a = ++n; // a contains the value of n after it's been incremented
and
a = n++; // a contains the value of n before it's incremented
For classes the situation is a bit different. It's up the class implementer to decide on the semantics of the operators - generally though you'd be asking for mockery to do something too off the wall and different from what built in types do. Cheers, Ash
-
Dear All, Very Good morning. I am facing some conceptual doubts in post increament and pre increament operators in for loop. Kindly follow the code below: for(int i=0;i<5;i++) { cout<French is the language of love, for everything else there is c++ ...(anonymous)
I saw the same question from you in Q&A. Please, don't post the same question to multiple forums.
-
Dear All, Very Good morning. I am facing some conceptual doubts in post increament and pre increament operators in for loop. Kindly follow the code below: for(int i=0;i<5;i++) { cout<French is the language of love, for everything else there is c++ ...(anonymous)
I agree with Sauro. If I'd seen the question here before I went to the effort of answering it in QA, I wouldn't have taken the trouble.
Software rusts. Simon Stephenson, ca 1994.