Basic Example

suggest change

This 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.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents