2013年6月9日日曜日

C++メモ 〜 auto 〜

参照

autoは右辺値の型を表す。ただし、上位のconstや&は省かれる。


autoは全てintである。
&は無視されるので、autoはintである。
ipの型はint*である。autoはそのままint*である。
上位のconstと&が無視されるので、autoはintである。
cipの型は、pointer to const intである。ここに現れるconstは上位のものではない。したがって、autoは const int*である。
ipcの型は、const pointer to intである。ここに現れるconstは上位のものである。したがって、autoはint*である。
cipcの型は、const pointer to const intである。上位のconstだけが落とされるので、autoはconst int*である。
autoはstd::initializer_list<int>である。

0 件のコメント:

コメントを投稿