C++ Language/Type/Shortcuts/FromAnotherVariable

From Wikibooks, open books for an open world
Jump to navigation Jump to search

If variable iOtherVar has already been defined to have type int, then definition decltype(iOtherVar) iVar = 22; is the same as defining int iVar = 22;. This decltype() shortcut can even refer to a full expression.

Additional information about decltype (includes interactive examples)