更新时间:2023-02-06 18:14:16
您不能做到这一点:
const int* bar = {1, 2, 3};
但你可以这样做:
But you can do this:
const int bar[] = {1, 2, 3};
原因是C(或C ++)有一个附加的功能,除了作为一个字符指针工作,它也可以作为一个C字符串,从而增加初始化方法(特别对于char *)的字符*:
Reason is that char* in C (or C++) have an added functionality, besides working as a char pointer, it also works as a "C string", thus the added initialization method (special for char*):
const char* foo = "This is bare-string";
***的。