C++ - 数组是指针吗?

Sim*_*ity 1 c++ arrays pointers

可能重复:
C:指针和数组之间的差异

arrayC++一个pointer?你能澄清一下吗?

谢谢.

Eri*_*rik 8

不,但是只要你需要它就可以衰减到指针.

void foo1(char * c) {
}


int main() {
  char Foo[32];
  foo1(Foo); // Foo decays to a pointer
  char * s = Foo; // Foo decays to a pointer which is assigned to s
}
Run Code Online (Sandbox Code Playgroud)