0

アドレス演算子 (&) と間接演算子 (*) のさまざまな書き方を見てきました。

私が間違っていなければ、次のようになります。

//examples
int var = 5;
int *pVar = var;

cout << var << endl; //this prints the value of var which is 5

cout << &var << endl; //this should print the memory address of var

cout << *&var << endl; //this should print the value at the memory address of var

cout << *pVar << endl; //this should print the value in whatever the pointer is pointing to

cout << &*var << endl; //I've heard that this would cancel the two out

たとえば、2 つの間にスペースを入れて&varasと書いたらどうなるでしょうか。& var私が見た一般的な構文: char* line = var;char * line = var;、およびchar *line = var;.

4

1 に答える 1