8. References

Question.3

A firmware engineer designs a function that configures a UART peripheral. The UART object always exists when the function is called. Which parameter style is best?

Option A — Pointer:

void configure_uart(UART_Driver *uart) {
   if (uart == nullptr) return;
   uart->setBaud(115200);
}

Option B — Reference:

void configure_uart(UART_Driver &uart) {
   uart.setBaud(115200);
}

Which is the better embedded C++ practice?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!