146. Inheritance

Question.8

A developer models a GPS module:

Option A -- Inheritance:

class GPS : public UART { /* GPS IS-A UART? */ };

Option B -- Composition:

class GPS {
   UART& uart;  // GPS HAS-A UART
public:
   GPS(UART& u) : uart(u) {}
};

Which is correct?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!