TypeDef
typedef existing_type new_type_name;typedef unsigned long ulong; ulong myNumber = 1000000UL;typedef int IntArray[5]; IntArray myArray = {1, 2, 3, 4, 5};typedef int* IntPtr; IntPtr ptr = new int(10);typedef int (*MathFunc)(int, int); int add(int a, int b) { return a + b; } MathFunc operation = add;typedef struct { int x; int y; } Point; Point p = {10, 20};typedef std::vector<std::pair<std::string, int>> NameScorePairs; NameScorePairs scores;template<typename T> using Vec = std::vector<T>; Vec<int> numbers = {1, 2, 3, 4, 5};typedef std::unique_ptr<MyClass> MyClassPtr; MyClassPtr ptr = std::make_unique<MyClass>();typedef long long int64; // Ensures 64-bit integer across platforms
Last updated