Errors you get due to a missing print version:
print('a'); // calling print(int) print(0); // calling print(int) print(3.14159); // calling print(double) not float
As you can see, print(int) and print(double) missing, and print(char) missing, you get these errors. When print(char) , for example, is not provided, looking for a compiler for print(int) in this way, it passes the passed value to an integer.
To solve this problem, you either add a version of the overloaded print , or explicitly pass the value passed to:
1- Print Overload:
void print(int value){ cout << "int: " << value << endl;} void print(unsigned int value){ cout << "ui: " << value << endl;} void print(float value){cout << "float: " << value << endl;} void print(char c){ cout << "Char: " << c << endl;} void print(double value){cout << "double: " << value << endl;}
2- Casting:
print((unsigned int)'a'); // or (float) print((unsigned int)0); // or (float) print(3.14159f); // or (float)3.14159 or (unsigned int)3.14159
- Keep in mind that
print(3.14159); - call print(double); no float to do this for float: print(3.14159f);
source share