NOTE. I know that there are many questions that talked about this, but I am still a beginner and I could not understand the examples.
I got a function prototype that looks something like this:
int someFunction(const char * sm);
Here, as you know, const char * means that this function can accept const or non-const pointer-to-char. I tried something like this in the function body:
someMemberVar = sm;
someMemberVar is just a pointer to a char. The compiler tells me an error: cannot convert from const char * to char *.
I did not pass a constant here, so sm or someMemberVar are not constants. So what constant is the compiler talking about?
c ++ const
Loai nagati
source share