如果變數 iOtherVar 已經定義為 int 型別,那麼定義 decltype(iOtherVar) iVar = 22; 與定義 int iVar = 22; 相同。這個 decltype() 快捷方式甚至可以引用完整的表示式。
iOtherVar
int
decltype(iOtherVar) iVar = 22;
int iVar = 22;
decltype()
關於 decltype 的更多資訊(包括互動式示例)