Given the following class specification: a. Suppose class B publicly inherits fr
ID: 3797398 • Letter: G
Question
Given the following class specification: a. Suppose class B publicly inherits from class A. What will class B inherit from a? b. Suppose class B privately inherits from class A. What will class B inherit from A? class A {public: void f(); int %(); int gatz(); protected: void h(int); int k(int); int y; private: void fp(); int z;}; Indicate whether the relationship between the classes is composition or inheritance? a. shape, Right Triangle, and Polygon b. and Card c. Employee and Human d. word Counter (Assignment 2) and vector e. Vampire and FangExplanation / Answer
8.
a) class B : public A
# class A all public variables & method remain public and gets inherited
# class A all protected variables & method remains protected and gets inherited
# class A all private variables & method doesn't get inherited.
b) class B : private A
# class A all public variables & method gets inherited and converts to private
# class A all protected variables & method gets inherited and converts to private
# class A all private variables & method doesn't get inherited.
9.
a. Shape => Polygon => RightTriangle = Inheritance.
b. DeckofCards, Card = Composition
c. Employee inherits Human = Inheritance
d. WordCounter(Assignment 2) and vector = Composition.
e Vampire and Fang = Composition
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.