So, I know you can alias types with the following:
typedef int *intPtr
But the C++ compiler can\'t differentiate between them:
typedef int
A typedef
or using
statement will not introduce a new type.
To get a new type you need to define one:
struct foo { int x; };
struct bar { int x; };
int main()
{
//typedef int foo;
//typedef int bar;
foo x{5};
bar y{7};
int z = x + y; // now doesn't compile, wants an operator+() defined
return 0;
}
In the above example we take advantage of aggregate initialization to allow for the use of the structs
in this way.