OK, defining a new Datatype might be a bit of a stretch…how about, defining aliases?
You can use the typedef keyword to define a new aliase for an existing data type in C++. The general form is:
typedef existingType newType;
Let’s say you have experience with another language and you want to use a datatype name that they had. Or you want to simplify the unsigned sub-type, well typedef lets you do that.
typedef int integer; // now you can say integer x instead of int x;
typedef int* intp; // or integer pointer if you prefer
So why would you do something like that? Well, as you might imagine, it’s easy to forget to use a * when defining a variable. It’s not only easy to forget, it’s easy to overlook because it’s a single character and the datatype is right. This should help reduce confusion when writing code,and reducing confusion means less errors and less frustration.
Just a friendly little tip.
Defining New Datatypes was originally found on Access 2 Learn