#include <iostream>
using namespace std;
void foo(int x) {
cout << "int overload\n";
}
void foo(int* p) {
cout << "int* overload\n";
}
int main() {
foo(0);
foo(nullptr);
return 0;
}
Explanation & Logic Summary:
0 is an integer literal, so overload resolution selects foo(int).nullptr has type std::nullptr_t and converts only to pointer types, so foo(int*) is selected.NULL.Firmware Relevance & Real-World Context:
nullptr instead of integer literals or macros prevents: