Thread: const??

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001

    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...

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


  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001


    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
    Registered User
    Join Date
    Sep 2001
    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, 05:34 PM
  4. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01: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