In C++11, char pointers cannot be initialized to string literals directly.
In earlier versions of C++, I could do this with no issue.
If code below is allowed,
char arr[] = "Hello";
char *p_str1 = arr; //allowed
Then why the code below is not allowed?
char *p_str3 = "Hello"; //Not allowed
Note: I am aware adding const would fix. But need to know reasons.
Aucun commentaire:
Enregistrer un commentaire