我正在回顾“C ++编程语言”一书中的一些主题。在指针一章中,Stroustrup有以下例子:
int* pi; // pointer to int
char* ppc; // pointer to pointer to char
int* ap[15]; // array of 15 pointers to ints
int (*fp)(char*); // pointer to function taking a char* argument; returns an int
int* f(char*); // function taking a char* argument; returns a pointer to int
char* ppc; // this char has only one *, how can this a pointer to pointer to char?
这是书中的错误还是完全正确的?
答案 0 :(得分:3)
而不是
char* ppc; // pointer to pointer to char
应该是
char** ppc; // pointer to pointer to char
答案 1 :(得分:0)
这一定是书中的印刷错误。
您应该**
获取指向指针的指针
答案 2 :(得分:0)
应为char** ppc;
int* pi; // pointer to int
char** ppc; // pointer to pointer to char
int* ap[15]; // array of 15 pointers to ints
int (*fp) (char *); // pointer to function taking a char* argument; returns an int
int* f(char *); // function taking a char* argument; returns a pointer to int