case 1: you can overload two functions namely:
void foo(int *);
void foo(const int *);
while in , case 2: you can not overload two functions:>
In the second case, because integers are primitive type, the int
or const int
is passed by value, and the function makes a copy of the variable. Therefore, the function definition is the same.
In the first case, the first function takes in an integer pointer as a parameter, whereas the second function takes in a pointer to a constant integer. These are different data types, as the value of the integer is not copied by the value of the pointer is, and therefore the data is passed by reference.