c++ - static binding of default parameter -


In effective C ++, a sentence in the book mentions why the default parameters are static:

If the default parameter values ​​were dynamically binding, computers would have to come up with a way to determine the default values ​​appropriate for the parameters of the virtual function on the runtime, to determine the current mechanism of the compilation Slow and Fie will be complicated.

Can someone expand it a bit more? Why is it complicated and incompetent?

Thanks a lot!

Whenever a class is a virtual function, the compiler runs on runtime to support dynamic binding and polymorphic behavior Creates a so-called V-Table to calculate the necessary address. Lots of class adapter work toward deleting the virtual function due to this. Less overhead, and small code. If the default parameters were also calculated in the equation, then it would make the whole virtual function mechanism more complex and bloated.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -