-2

重複の可能性: const int*、const int * const、int const *定数ポインター
の違いは何ですか

これら2つのステートメントに違いはありますか?

void * const sam;

void const *sam;
4

3 に答える 3

2
void * const sam;

ポインターは読み取り専用です。修飾子は . の後にあり*ます。

void const *sam;

指示先は読み取り専用です。修飾子は の前にあり*ます。

于 2012-08-21T11:20:15.340 に答える
0
const int * Constant

Constant が定数整数への変数ポインターであることを宣言し、

int const * Constant

同じことを行う代替構文ですが、

int * const Constant

Constant3 が可変整数への定数ポインターであることを宣言し、

ソース:

http://duramecho.com/ComputerInformation/WhyHowCppConst.html

于 2012-08-21T11:20:54.020 に答える
0

はい。

voidに変更後int

int * const sam;
sam = NULL; /* invalid */
*sam = 42; /* valid */

また

int const *sam;
sam = NULL; /* valid */
*sam = 42; /* invalid */
于 2012-08-21T11:21:34.433 に答える