Study Guide 10: Multi-Class Programs


The following questions refer to the UML class diagram at the right.
The connector between Alpha and Gamma has a solid diamond attached to Alpha. The connector between Beta and Delta has an outlined diamond attached to Beta. The connector between Gamma and Delta has an outlined, three-sided arrowhead attached to Gamma. The connector between Gamma and Zeta is an undecorated line. A dashed line connects Delta and Epsilon with an open arrowhead attached to Epsilon.

Identify the class relationship represented by each code fragment.
  • class Ceres
    {
        ...
    };
    
    class Vesta
    {
        private:
            Ceres* c;
    };
 
  • class Pallas
    {
        ...
    };
    
    class Hygiea
    {
        private:
            Pallas p;
    };
  • class Doris
    {
        ...
    };
    
    class Cybele
    {
        public:
            void function()
            {
                Doris d;
                ...
            }
    };
 
  • class Hektor;
    
    class Camilla
    {
        private:
            Hektor* h;
    };
    
    class Hektor
    {
        private:
            Camilla* c;
    };
  • class Psyche
    {
        ...
    };
    
    class Fortuna
    {
        public:
            void function(Psyche p);
    };
 
  • class Europa
    {
        ...
    };
    
    class Juno : public Europa
    {
        ...
    };

Identify each Match each statement as describing either overloaded or overridden functions.

Use the UML class diagram to complete the class B initializer list
B(int w, int x, int y, int z) : ______________________; Three classes connected by inheritance and composition:
A
--

--
+ A(w : int, x : int)

B
--

--
+ B(w : int, x :int, y : int, z : int)

C
--

--
+ C(y :int, z : int)

B is a subclass of A; B is a whole and C is a part.