Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. A simple question about variable

A simple question about variable

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maer727
    wrote on last edited by
    #1

    - What does the following sentence mean? - Variable is a constant the compiler knows the value at compile time. - Can you show me an example? - Regards, Maer

    B N A 3 Replies Last reply
    0
    • M Maer727

      - What does the following sentence mean? - Variable is a constant the compiler knows the value at compile time. - Can you show me an example? - Regards, Maer

      B Offline
      B Offline
      Bernhard
      wrote on last edited by
      #2

      couldn't it be the other way round: constant is a variable the compiler knows the value at compile time.. makes much more sense for me... bernhard


      ""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."

      M 1 Reply Last reply
      0
      • M Maer727

        - What does the following sentence mean? - Variable is a constant the compiler knows the value at compile time. - Can you show me an example? - Regards, Maer

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        Variable is a constant the compiler knows the value at compile time Are you talking about const variables? Nish Sonork ID 100.9786 voidmain

        M 1 Reply Last reply
        0
        • M Maer727

          - What does the following sentence mean? - Variable is a constant the compiler knows the value at compile time. - Can you show me an example? - Regards, Maer

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          - Where did this sentence come from? - It probably means that since the variable is declared "const", the compiler will know its exact value while it's compiling the file(s) that use it. Thus it can reliably use the variable for such things as allocating memory for arrays. - Example: const int MAX_ITEMS = 20; Item items[MAX_ITEMS]; - Regards, Alvaro

          M 2 Replies Last reply
          0
          • N Nish Nishant

            Variable is a constant the compiler knows the value at compile time Are you talking about const variables? Nish Sonork ID 100.9786 voidmain

            M Offline
            M Offline
            Maer727
            wrote on last edited by
            #5

            - I am talking about ordinary variables. - Regards, Maer

            1 Reply Last reply
            0
            • B Bernhard

              couldn't it be the other way round: constant is a variable the compiler knows the value at compile time.. makes much more sense for me... bernhard


              ""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."

              M Offline
              M Offline
              Maer727
              wrote on last edited by
              #6

              - Take a look at the following program: #include using namespace std; class a{ private: static const int s ; int i[s]; }; const int a:: s=20; void main() { cout<

              1 Reply Last reply
              0
              • A Alvaro Mendez

                - Where did this sentence come from? - It probably means that since the variable is declared "const", the compiler will know its exact value while it's compiling the file(s) that use it. Thus it can reliably use the variable for such things as allocating memory for arrays. - Example: const int MAX_ITEMS = 20; Item items[MAX_ITEMS]; - Regards, Alvaro

                M Offline
                M Offline
                Maer727
                wrote on last edited by
                #7

                - Thanks, Alvaro pal! - Take a look at the following program: #include using namespace std; class a{ private: static const int s ; int i[s]; }; const int a:: s=20; void main() { cout<

                1 Reply Last reply
                0
                • A Alvaro Mendez

                  - Where did this sentence come from? - It probably means that since the variable is declared "const", the compiler will know its exact value while it's compiling the file(s) that use it. Thus it can reliably use the variable for such things as allocating memory for arrays. - Example: const int MAX_ITEMS = 20; Item items[MAX_ITEMS]; - Regards, Alvaro

                  M Offline
                  M Offline
                  Maer727
                  wrote on last edited by
                  #8

                  - Thanks, Alvaro pal! - Take a look at the following program: #include using namespace std; class a{ private: static const int s ; int i[s]; }; const int a:: s=20; void main() { cout<

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups