• Lucid Dreaming - Dream Views




    Results 1 to 25 of 102
    Like Tree3Likes

    Thread: Ask me about C / C++

    Hybrid View

    1. #1
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Yes. But behind the scenes, it's a little more complicated than that.

      Code:
      int a = 0;
      int b = a++;
      //b equals 0 here, while a = 1
      Here's what actually happened.
      a was created and initialized to zero
      a was copied
      a was incremented
      b was created, then initialized to the copy

      Code:
      int a = 0;
      int b = ++a;
      //a and b both equal 1
      a was created and initialized to 0
      a was incremented
      b was created and initialized to zero

      The difference is that copy. Copying takes time and in the case a few posts ago, a copy is not needed and just wastes ram and cpu power. Optimizing software is all about removing extra steps.
      spacechase0 likes this.

    2. #2
      Ex Tech Admin Achievements:
      Created Dream Journal Tagger First Class Veteran First Class 10000 Hall Points Populated Wall Referrer Gold Made lots of Friends on DV
      slash112's Avatar
      Join Date
      Nov 2008
      Gender
      Location
      Sunny Scotland
      Posts
      5,113
      Likes
      1567
      DJ Entries
      29
      Ohhhhhh, I seee.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •