Other My basic c++ program (not) working as intended

Discussion in 'Software' started by Edge102030, 11 Feb 2011.

  1. azrael-

    azrael- I'm special...

    Joined:
    18 May 2008
    Posts:
    3,852
    Likes Received:
    124
    Actually, you'd probably be better off declaring pi as:

    const double pi = 3.14159265;

    Defines can be very annoying. Especially since they're pre-processor statements and not actual values, i.e. the *text* "3.14159265" is substituted for the *text* "pi" prior to compilation.

    Oh, and we ALL know that pi == 3. :D
     
  2. Daedelus

    Daedelus What's a Dremel?

    Joined:
    7 May 2009
    Posts:
    253
    Likes Received:
    12
    Yes I stand corrected, although I wasn't really referring to member variables, but I guess that serves me right for generalising.

    Anyway, you could argue that in your example you do initialise the variable when it's created, since you set its value in the constructor and "a" does not exist until you instantiate the DaedelusIsWrong class :D
     

Share This Page