This is the error message that you see whenever you encounter this situation:
char* pointer_to_nonconst = "string literal";
What for? Well, C and C ++ are different in type of string literal. In C, the type is a char array, while in C ++ it is a constant char array. In any case, you are not allowed to change the characters of a string literal, so const in C ++ is actually not a limitation, but rather a type safety issue. Converting from const char* to char* usually not possible without an explicit cast for security reasons. But for backward compatibility with C, the C ++ language still allows you to assign the string literal char* and gives a warning that this conversion is not recommended.
So, somewhere you are missing one or more const in your program for const to be correct. But the code you showed us is not a problem, since it does not do this kind of obsolete conversion. The warning must have come from another place.
sellibitze Oct 06 '09 at 9:23 2009-10-06 09:23
source share