29. Overload Resolution Trap

Write two overloaded functions with the same name but different parameter types:

void foo(int x);
void foo(int* p);

The goal is to demonstrate how overload resolution behaves differently for integer literals and nullptr in modern C++.

The program will explicitly call:

foo(0);
foo(nullptr);

You only need to implement the two overloads so that each prints which overload was selected.

  • foo(int) must print:
    • int overload
  • foo(int*) must print:
    • int* overload

 

Example Output:

int overload
int* overload

 

 

 

 

Loading...

Input

Expected Output

int overload int* overload