540 pdfsam Cplusplus Primer Plus 4th Edition

This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks C++ ...

0 downloads 2 Views 2KB Size
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

C++ functions, by default, have external storage class, so they can be shared across files. But functions qualified with the keyword static have internal linkage and are confined to the defining file. Namespaces let you define named regions in which you can declare identifiers. The intent is to reduce name conflicts, particularly in large programs using code from several vendors. Identifiers in a namespace can be made available by using the scope resolution operator, by using a using-declaration, or by using a using-directive.

Review Questions

.1:

What storage scheme would you use for the following situations?

a. homer is a formal argument (parameter) to a function. b. The secret variable is to be shared by two files. c. The topsecret variable is to be shared by the functions in one file but hidden from other files.

d. beencalled keeps track of how many times the function containing it has been called.

.2:

Discuss the differences between a using-declaration and a using-directive.

.3:

Rewrite the following so that it doesn't use using-declarations or using-directives.

#include using namespace std; int main() { double x; cout << "Enter value: "; while (! (cin >> x) )