> So my question is in what kind of situation would I apply other data types rather than just using int, float, char?
Use
int as the default integer type,
double as the default floating point type,
char as the default character type, and
std::string as the default string type.
Consider using some other type in place of these only if there are externally imposed constraints that make
int,
double,
char or
std::string unsuitable.
In particular, the logic that goes something like: 'an
int can represent a maximum value of
x, so if you want larger values, use
long' is fundamentally unsound. At best, it provides a non-portable solution.
If you want fixed or minimum width integer types, use the types in <cstdint>
http://en.cppreference.com/w/cpp/header/cstdint
If you want a signed integer type that can hold 12 decimal digits, use something like:
decltype(999999999999) i = 0 ;