'Does function pointers work while I am overloading the functions?

I am just practicing function pointers.

#include <iostream>
#include <functional>

void print(){
    std::cout << "Printing VOID...\n";
}
void printI(int a){
    std::cout << "Printing INTEGER..."<<a<<"\n";
}
int main(){
    std::function<void(void)> p;
    std::function<void(int)> pi;
    p = print;
    pi = printI;
    p();
    pi(10);
}

Now this code works fine and gives me the output.. But what i want to do is to overload the print function like below.

#include <iostream>
#include <functional>

void print(){
    std::cout << "Printing VOID...\n";
}
void print(int a){
    std::cout << "Printing INTEGER..."<<a<<"\n";
}
int main(){
    std::function<void(void)> p;
    std::function<void(int)> pi;
    p = print;
    pi = print;
    p();
    pi(10);
}

But This code isn't working. It says unresolved address for print. Is there any way I can achieve both functionality? I mean Function pointer and Overloading.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source