2 ms·
When would that default value be initialized?
by planede 2y ago
When would that default value be initialized?
- jstanley 2y agoThe same time the function pointer is initialised, and from the same source. If you like, consider it to be 2 different functions. One takes an argument, one has a fixed value.
- planede 2y agoThe function pointer is initialized at build time, and put into a read-only section in the executable. This is impossible for default arguments, in general. Many of them would need to be dynamically initialized. Anyway, it's more than one way antithetical how default arguments work in C++. It's not Python, C++ doesn't have default argument objects in any shape and form. Default argument expressions are expected to be evaluated at call time, with all of its observable implications. The feature itself doesn't mesh well with virtual functions, but there is no reasonable way to resolve it. You either break the intuitions for virtual functions or to default arguments.