C++ deprecated conversion from string constant to 'char*'

前端 未结 11 1271
傲寒
傲寒 2020-11-22 16:01

I have a class with a private char str[256];

and for it I have an explicit constructor:

explicit myClass(const char *func)
{
    strcpy(         


        
11条回答
  •  遇见更好的自我
    2020-11-22 16:34

    I also got the same problem. And what I simple did is just adding const char* instead of char*. And the problem solved. As others have mentioned above it is a compatible error. C treats strings as char arrays while C++ treat them as const char arrays.

提交回复
热议问题