I have three functions:
#include <iostream>
-
Which takes parameter as normal:
int*
void func(int * para)
{
std::cout << “Printing function without const” << *para << std::endl;
} -
Which takes parameter as low level const:
const int* para
void func(const int *para)
{
std::cout << “Printing function with low level const” << *para << std::endl;
}
3)Last which takes parameter as top level const: int *const para
void func(int *const para)
{
std::cout << "top level one" << *para << std::endl;
}
Ques1) One & two are perfect overloaded functions but one and three aren’t why?
int main()
{
int j= 4435;
const int i = 34;
func(&j); //For first function
func(&i); //For second function
// But then i have to remove 3rd function from the code because in that case overloading fails? Why exactly that happens?
return 0;
}
Ques 2) As I know
int j =34 ;
const int *ptr = &j;
const can also take non-const. So, why even the second function is considered as overloaded function?