const??

This is a discussion on const?? within the C++ Programming forums, part of the General Programming Boards category; On this board, i've seen people post code and sometimes when they declare a variable, (such as a float or ...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Thumbs up const??

    On this board, i've seen people post code and sometimes when they declare a variable, (such as a float or double ect.) they put const befor it. I 'll give you an example...

    Code:
    const float var;
    See what I mean? Please explain this to me somebody.

    Thanks
    -Chris
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343

    Talking

    The variable var can not change value. You should also initiate all const declared variables i.e

    const float pi= 3.14;

    ----------------------------------------------------------------------------------
    Veni Vidi Vici

  3. #3
    edk
    edk is offline
    Registered User
    Join Date
    Sep 2001
    Posts
    20
    if it's just const float var; then it assigns whatever default value the compiler assigns to it to a constant float value. so, you can't change it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 04:34 PM
  4. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21