Aliases and pointers address (forgive the pun) completely different issues (but see below). An alias allows you to define your own name for an existing, predefined type of variable. In C++ (since C++11), you can use the using
keyword to define an alias:
using MYINT = int;
After the above code, you can use the name MYINT
(the alias) anywhere you would otherwise use an int
declaration; thus, the following two lines would then be equivalent:
int i;
MYINT i;
Before C++11 (and even in plain C), aliases are also available, using the typedef
keyword:
typedef int MYINT;
However, what may be confusing you is the use of the term "aliasing" (or "strict aliasing rules") when referring to pointers. These terms refer to the rules required when attempting to access one type of object through a pointer that is (formally) the address of a different type of object. This subject has been discussed in numerous posts on Stack Overflow; for example: What is the strict aliasing rule?