Consider:
void func_print(int value) {
std::cout << “int” << std::endl;
}
void func_print(void* value) {
std::cout << “void” << std::endl;
}
int main() {
func_print(0);
func_print(NULL);
}
I can’t seem to find the reason. My compiler may be broken, because it gives me stray errors. I can’t find out what is wrong.
g++: error: -E or -x required when input is from standard input
c.cpp:3:5: error: stray ‘\342’ in program
std::cout << “int” << std::endl;
^
c.cpp:3:5: error: stray ‘\200’ in program
c.cpp:3:5: error: stray ‘\234’ in program
c.cpp:3:5: error: stray ‘\342’ in program
c.cpp:3:5: error: stray ‘\200’ in program
c.cpp:3:5: error: stray ‘\235’ in program
c.cpp:6:5: error: stray ‘\342’ in program
std::cout << “void” << std::endl;
^
c.cpp:6:5: error: stray ‘\200’ in program
c.cpp:6:5: error: stray ‘\234’ in program
c.cpp:6:5: error: stray ‘\342’ in program
c.cpp:6:5: error: stray ‘\200’ in program
c.cpp:6:5: error: stray ‘\235’ in program
c.cpp: In function ‘void func_print(int)’:
c.cpp:3:21: error: expected primary-expression before ‘int’
std::cout << “int” << std::endl;
^
c.cpp: In function ‘void func_print(void*)’:
c.cpp:6:21: error: expected primary-expression before ‘void’
std::cout << “void” << std::endl;
^
c.cpp: In function ‘int main()’:
c.cpp:11:20: error: call of overloaded ‘func_print(NULL)’ is ambiguous
func_print(NULL);
^
c.cpp:2:6: note: candidate: void func_print(int)
void func_print(int value) {
^
c.cpp:5:6: note: candidate: void func_print(void*)
void func_print(void* value) {
All errors here are explained with messages, though I don't get it exactly what is wrong.