This question is a follow-up question of this one.
Consider the following program:
#include <cmath>
// meaningless, only for language-lawyer purpose
void abs(void*) {}
int main(){
abs(nullptr);
}
Does this program result in undefined behavior?
The related part in the standard is [extern.names]/4:
Each function signature from the C standard library declared with external linkage is reserved to the implementation for use as a function signature with both extern "C" and extern "C++" linkage, or as a name of namespace scope in the global namespace.
I'm not sure whether overloading is permitted.
2) Member function declarations with the same name and the name parameter-type-list cannot be overloaded if any of them is a static member function declaration.
Yes, it's called function overloading. Multiple functions are able to have the same name if you like, however MUST have different parameters.
C++ lets you specify more than one function of the same name in the same scope. These functions are called overloaded functions, or overloads.
Q) Which function cannot be overloaded in C++ program? Static functions cannot be overloaded in C++ programming.
There are two parts to this statement, as it talks about names (from the C standard) that are reserved (for C++ implementations). In particular,
Part 1: Each function signature from the C standard library declared with external linkage
This includes the C library function abs
Part 2: is reserved to the implementation for use as a function signature with both extern "C" and extern "C++" linkage, or as a name of namespace scope in the global namespace.
So the name ::abs
is reserved for the C++ implementation. You can't use it. Overloading is irrelevant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With