Review Questions

1:What storage scheme would you use for the following situations?
  1. homer is a formal argument (parameter) to a function.

  2. The secret variable is to be shared by two files.

  3. The topsecret variable is to be shared by the functions in one file but hidden from other files.

  4. 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 <iostream> using namespace std; int main() { double x; cout << "Enter value: "; while (! (cin >> x) ) { cout << "Bad input. Please enter a number: "; cin.clear(); while (cin.get() != '\n') continue; } cout << "Value ...

Get C++ Primer Plus, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.