Sams Teach Yourself C++ in 21 Days

(singke) #1
82: (obj3.*PMF)();
83: cout << “Static: “ << myClass::GetStatic() << endl;
84:
85: return 0;
86: }

Day 16


Quiz


  1. Anis-arelationship is established with public inheritance.

  2. A has-arelationship is established with aggregation (containment); that is, one
    class has a member that is an object of another type.

  3. Aggregation describes the idea of one class having a data member that is an object
    of another type. Delegation expresses the idea that one class uses another class to
    accomplish a task or goal.

  4. Delegation expresses the idea that one class uses another class to accomplish a task
    or goal. Implemented in terms ofexpresses the idea of inheriting implementation
    from another class.

  5. A friend function is a function declared to have access to the protected and private
    members of your class.

  6. A friend class is a class declared so that all of its member functions are friend
    functions of your class.

  7. No, friendship is not commutative.

  8. No, friendship is not inherited.

  9. No, friendship is not associative.

  10. A declaration for a friend function can appear anywhere within the class declara-
    tion. It makes no difference whether you put the declaration within the public:,
    protected:, or private:access areas.


Exercises


  1. The following is one possible answer:
    class Animal:
    {
    private:
    String itsName;
    };


856 Appendix D

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

Free download pdf