14. Function Overloading

Question.6

A developer needs a timer init function that optionally accepts a prescaler. Which approach uses less Flash?

Option A — Overloading:

void timer_init(int period) { timer_init(period, 1); }
void timer_init(int period, int prescaler) { /* setup */ }

Option B — Default argument:

void timer_init(int period, int prescaler = 1) { /* setup */ }
Need Help? Refer to the Quick Guide below

Select Answer