Answered Questions

  • What is the benefit of using const for declaring constants?

    The benefit of using the const keyword is that the compiler might be able to make optimizations based on the knowledge that the value of the variable will not change. In addition, the compiler will try to ensure that the values won’t be changed inadvertently. Of course, the same benefits apply to #defined constants. The reason to use const rather than #define to define a constant is that a const variable...

    hurdjg

    • May 30th, 2007

    A side effect benefit:Say you want to pass an argument that you do not want modified, but you do not want to pass by value.Solution pass as constant reference or pointer constant...

    hurdjg

    • May 30th, 2007

    A side effect benefit:Say you want to pass an argument that you do not want modified, but you do not want to pass by value.Solution pass as constant reference or pointer constant...