|Q1:||Why not make all variables global?|
||There was a time when this was exactly how programming was done. As programs became more complex, however, it became very difficult to find bugs in programs because data could be corrupted by any of the functions--global data can be changed anywhere in the program. Years of experience have convinced programmers that data should be kept as local as possible, and access to changing that data should be narrowly defined.|
|Q2:||Why aren't changes to the value of function arguments reflected in the calling function?|
||Arguments passed to a function are passed by value. That means that the argument in the function is actually a copy of the original value.|
|Q3:||What happens if I have the following two functions? ...|
Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.