Basic Example
suggest changeThis example just illustrates how this keyword can be used.
int a = 10;
// Assume that type of variable 'a' is not known here, or it may
// be changed by programmer (from int to long long, for example).
// Hence we declare another variable, 'b' of the same type using
// decltype keyword.
decltype(a) b; // 'decltype(a)' evaluates to 'int'
If, for example, someone changes, type of ‘a’ to:
float a=99.0f;
Then the type of variable b
now automatically becomes float
.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents