can you please give differences between default and constant arguments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vasavi reddy
    New Member
    • Jan 2015
    • 1

    can you please give differences between default and constant arguments

    More explanation about default and constant arguments
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    If you fail to supply a value for an argument, a default value can be provided.

    A constant argument means the function will not change the value of the argument.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Are you asking about command line arguments?

      Unless you're doing something tricky, the function prototype will coerce you into supplying all the function arguments -- there cannot be such a thing as default function arguments. However, there are tricky ways to get around this.

      Are you referring to the const keyword when you say "constant arguments"? You will get a compiler error if you try to change the value of a function argument that is declared const.

      C uses call-by-value. This means that changes made to an argument inside a function are not seen by the code that called the function. (There are tricky ways to get around this too.)

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        There are default function argumenta in C++ but not in C.

        That is to say, default VALUES for function arguments.

        Comment

        Working...