Sams Teach Yourself C++ in 21 Days

(singke) #1
23: if ((ch > 32 && ch < 127) || ch == ‘\n’|| ch == ‘\t’)
24: cout << ch;
25: fin.close();
26: }


  1. The following is one possible solution:
    0: // Ex1705.cpp
    1: #include
    2:
    3: int main(int argc, char**argv) // returns 1 on error
    4: {
    5: for (int ctr = argc-1; ctr>0 ; ctr--)
    6: std::cout << argv[ctr] << “ “;
    7: }


Day 18


Quiz

1.Outer::Inner::MyFunc();


  1. At the point the listing reaches HERE, the global version of Xwill be used, so it will
    be 4.

  2. Yes, you can use names defined in a namespace by prefixing them with the name-
    space qualifier.

  3. Names in a normal namespace can be used outside of the translation unit where the
    namespace is declared. Names in an unnamed namespace can only be used within
    the translation unit where the namespace is declared.

  4. The usingkeyword can be used for the usingdirectives and the usingdeclara-
    tions. A usingdirective allows all names in a namespace to be used as if they are
    normal names. A usingdeclaration, on the other hand, enables the program to use
    an individual name from a namespace without qualifying it with the namespace
    qualifier.

  5. Unnamed namespaces are namespaces without names. They are used to wrap a col-
    lection of declarations against possible name clashes. Names in an unnamed name-
    space cannot be used outside of the translation unit where the namespace is
    declared.

  6. The standard namespace stdis defined by the C++ Standard Library. It includes
    declarations of all names in the Standard Library.


862 Appendix D

32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 862

Free download pdf