c++ - Is usage of Default parameters healthy habit or a bad one? -


when should use default parameters? proper syntax , should not used? using them regularly or bad habit? affect efficiency?

only case can think of affects efficiency when include big default parameter it's not used of callers. example:

#include <iostream> void foo(std::ostream& out=std::cout) {     out << "foo"; } 

if none of callers use default parameter, , rest of program doesn't need <iostream> have been included in vain, increasing executable size (and compilation time may or may not matter much).


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -