Errors C++
If it starts with C, then it is a compiler error.
If it starts with L, then it is a linker error.
test local function definitions are illegal C++
It appears if you accidentally defined a function not before main but inside main.
Error C2660 : function does not take 3 arguments
The compiler expects the function to have a different number of arguments.
It appears, for example, if you did not include the needed function, but there is
an overloaded function with a different number of arguments. The compiler does not find
the needed function, finds the one with the same name, tries to use it,
but the number of arguments is wrong.
Error LNK2019 unresolved external symbol
The linker sees that a function is called that is not defined anywhere.
Comparison between pointer and integer (E0042 in Visual Studio)
It usually appears when comparing char with a character in double quotes: a double-quoted literal is a C string, not a char.
char s = line[0];
if (s == "T") {
std::cout << "TopBicycle.ru" << std::endl;
}
e0042.cpp:9:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
You need to replace the double quotes with single ones.
char s = line[0];
if (s == 'T') {
std::cout << "TopBicycle.ru" << std::endl;
}
Empty character constant (E0025 in Visual Studio)
It appears when you try to create an empty string but do it with single quotes.
You need to replace the single quotes with double ones.
std::string empty_line = '';
empty_line.cpp:3:26: error: empty character constant
std::string empty_line = "";
'cout' in namespace 'std' does not name a type
error: 'cout' in namespace 'std' does not name a type
Most likely the output is written outside a function: a statement belongs in a body.
std::cout << "Hello";
C++ refuses that, so the output goes inside a function
void log() { std::cout << "Hello"; }
undefined reference to `std::cout'
undefined reference to `std::cout'
It means the C++ standard library was not linked: the file was compiled with gcc instead of g++.
The code on this page was run with g++ 15.2.0 on Alpine Linux 3.24.3 (x86_64) in a Docker container.
Article author: Andrei Olegovich