Types can be given an alias to be more descriptive and reduce verbosity for especially long types. Type aliasing does not create a new type:
typedef std::pair#include <utility><int, int> Point;
Point p(1, -2);With a function pointer:
typedef void (*Callback)(int);
void foo(Callback cb) {
cb(12);
}using is another way to declare a type alias:
using Point = std::pair#include <utility><int, int>;With a function pointer:
using Callback = void (*)(int);A using alias can be a template:
template <typename T>
using Point = std::pair#include <utility><T, T>;
Point<double> p(1.23, 4.56);Note
Prefer using over typedef since it can be templated.
Dan