119. Copy Semantics-I

Question.8

A derived driver is assigned to a base variable by value:

class Driver { public: int type; };
class UART_Driver : public Driver {
public:
   int baud;
   UART_Driver(int b) : baud(b) { type = 1; }
};

UART_Driver uart(9600);
Driver base = uart;  // Value copy to base type
printf("%d", base.type);
// Can we access base.baud?

What happens to the baud member?

Need Help? Refer to the Quick Guide below

Select Answer