2012-11-23 75 views

回答

2

如果您以正確的方式對事物進行分組,則會更容易一些。例如,*const實際上是一個單位,意思是「const指向」(您可以在這裏讀取const作爲下標:*const)。我會把它寫成:

const int *const *const p1; // p1 is a const pointer to const pointer to const int 
const int **p2; // p2 is a pointer to pointer to const int 

還要記住聲明讀取「從裏到外」,從聲明的標識符開始。

8

如何讀取這些結構?

反向讀取它們並將*讀作「指向」。

const int* const* const 

是一個常量指針指向一個整型常量的常量指針。

const int** 

是指向一個整型常量的指針。

2

有一個工具,它是非常有用/有趣破譯聲明:http://cdecl.ridiculousfish.com/

在你的情況報告: const int* const* const x => x聲明爲const指針常量指針const int的 const int** x => x聲明爲指針指向常量的指針int