• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Results 1 to 6 of 6
    1. #1
      Coder
      Wishing Trove had logical
      values.
       
      Steam Gaming
       
      maymonaise's Avatar
      Join Date
      Nov 2012
      Location
      Rhode Island, United States (GMT -500)
      Posts
      213
      Thanks (-->)
      40
      Thanks (<--)
      13

      Question Constant intergers vs. intergers?

      John Kittz
      Hey,
      I was wondering what the difference is between using a
      constant or just a plain variable. I know it's a newb question
      but I need to know early on.

      Code:
      const int ALIEN_POINTS = 150;
      vs.
      Code:
      int alien_points = 150;

    2. #2
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      -Tek's Avatar
      Join Date
      Sep 2012
      Location
      France
      Posts
      30
      Thanks (-->)
      1
      Thanks (<--)
      1
      a const can't be changed because it's constant ^^

      for exemple if you make a variable with the number of rock in a glass of water (shitty exemple but fuck), you know it won't change, so you declare it as a const

    3. #3
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      const keyword stands for constant, I see that you've made that clear already.

      Now, I suggest you to get a programming book and learn it from the beginning. It has all the answers.

      With const, you initialize a data variable which you don't have to (you CAN'T) change later on.
      Therefore you cannot compare const int with just int.

      const comes in handy when you declare something and don't have to change it later on, ie:
      Code:
      const int fiveHundredDollars = 500
      You wouldn't want to accidentally change the value of fiveHundredDollars, would you?
      Constant intergers vs. intergers?

    4. #4
      Coder
      Wishing Trove had logical
      values.
       
      Steam Gaming
       
      maymonaise's Avatar
      Join Date
      Nov 2012
      Location
      Rhode Island, United States (GMT -500)
      Posts
      213
      Thanks (-->)
      40
      Thanks (<--)
      13
      Quote Originally Posted by -Tek View Post
      a const can't be changed because it's constant ^^

      for exemple if you make a variable with the number of rock in a glass of water (shitty exemple but fuck), you know it won't change, so you declare it as a const
      Quote Originally Posted by c5 View Post
      const keyword stands for constant, I see that you've made that clear already.

      Now, I suggest you to get a programming book and learn it from the beginning. It has all the answers.

      With const, you initialize a data variable which you don't have to (you CAN'T) change later on.
      Therefore you cannot compare const int with just int.

      const comes in handy when you declare something and don't have to change it later on, ie:
      Code:
      const int fiveHundredDollars = 500
      You wouldn't want to accidentally change the value of fiveHundredDollars, would you?
      Thanks a ton to both of you. By the way, I'm currently
      reading Beginning C++ Game Programming by
      Michael Dawson. Do you have any other ideas for
      books?

    5. #5
      RTFM
      Shootin Pool!
       
      Coding
       
      Syperus's Avatar
      Join Date
      Oct 2012
      Location
      127.0.0.1
      Posts
      436
      Thanks (-->)
      101
      Thanks (<--)
      131
      Quote Originally Posted by maymonaise View Post
      . Do you have any other ideas for
      books?
      I can hook you up with some books that helped me along the way. I'm recovering from a computer crash and still restoring all my backups so it'll take some time, but they should help you out. I'll shoot you a pm when i'm done.

    6. #6
      Coder
      Wishing Trove had logical
      values.
       
      Steam Gaming
       
      maymonaise's Avatar
      Join Date
      Nov 2012
      Location
      Rhode Island, United States (GMT -500)
      Posts
      213
      Thanks (-->)
      40
      Thanks (<--)
      13

      Cheats'n'Trainers
      Quote Originally Posted by keptix View Post
      I can hook you up with some books that helped me along the way. I'm recovering from a computer crash and still restoring all my backups so it'll take some time, but they should help you out. I'll shoot you a pm when i'm done.
      Sounds good, I'll be waiting! Thanks