typedef and using
- C++ now provides two ways to "nickname" a type.
-
typedef oldType newType;
-
using newType = oldtype;
- The first is old and inherited from C
- The second is part of C++11
- So this is not included in the book.
- But this is superior.
- Stroustrup explains why here.
- You should use the second.
- Here is a reference.
- Or just look at the code I have provided.
- When I create new types,
- I use camelcase like a function name.
- But I end with a T
-
using NumberT = int;
- Look at nicname.cpp