Saturday, September 25, 2010

What's The Appropriate Age To Be Fingered

c + + functions const

Features: evidence on the behavior of functions with parameters passed by reference and
with constant parameters;

arrays of integers or characters (strings )
are always passed to functions by reference (memory address),
if the declaration of the parameters in protoripo functions (or procedures) is added to the const parameter, the actual content of the array can not exercise the function changed

Comments: If you try to compile and run a program that contains a function that tries to modify data in an array passed as a constant, the compiler
(DevC + +) indicates an error:

C: \\ Users \\ lele \\ Desktop \\ cpp_funzioni_const.cpp In function `int f2 (const int *, int) ':
76 C: \\ Users \\ lele \\ Desktop \\ cpp_funzioni_const.cpp assignment of read-only location

executable: 4cpp_funzioni_const.exe

Source: 4cpp_funzioni_const.pdf

0 comments:

Post a Comment