Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. pre-post increament

pre-post increament

Scheduled Pinned Locked Moved C / C++ / MFC
c++
4 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj D Dubey
    wrote on last edited by
    #1

    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)

    A S P 3 Replies Last reply
    0
    • P Pankaj D Dubey

      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)

      A Offline
      A Offline
      Aescleal
      wrote on last edited by
      #2

      For a built in type and not using the result of the expression ++n; and n++; 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

      1 Reply Last reply
      0
      • P Pankaj D Dubey

        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)

        S Offline
        S Offline
        Sauro Viti
        wrote on last edited by
        #3

        I saw the same question from you in Q&A. Please, don't post the same question to multiple forums.

        1 Reply Last reply
        0
        • P Pankaj D Dubey

          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)

          P Offline
          P Offline
          Peter_in_2780
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups