Why compiler is calling first overloaded function not second one?

Consider following program.

#include <iostream>
void fun(const char a[]) {
    std::cout<<"function 1n"; 
void fun(char *a) {
    std::cout<<"function 2n"; 
int main() { 

What should I change in the program so that second function gets called instead of first one?

Source: c++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.