User-Defined Types

Dated Jun 4, 2022; last modified on Sat, 04 Jun 2022

Definition from C++

Built-in types are ones that can be built from the fundamental types (e.g. void, std::nullptr_t, int, bool, char, float, double ), the const modifier, and the declarator operators (e.g. int[3], int*, int&).

While the built-in types directly and efficiently represent the capabilities of conventional computer hardware, they’re too low-level to conveniently write advanced applications in. C++ abstraction mechanisms let programmers design and implement user-defined types using both built-in types and other user-defined types.

Before this, I thought user-defined types did not include STL types. I thought that user meant me, or library authors, but not the C++ language devs, who, I assume, write the STL.

User-defined types are often easier to use, less error prone, and typically as efficient as direct use of built-in types.

says that sometimes user-defined types can be more efficient than built-in types. When would this be? Maybe something like std::vector<bool> , which is possibly (implementation-defined) more space-efficient than a std::vector (and thus an array) of bool?

  1. A Tour of C++ (Second Edition). Chapter 2. User-Defined Types. Bjarne Stroustrup. 2018. ISBN: 978-0-13-499783-4 .
  2. Fundamental types - cppreference.com. en.cppreference.com . Accessed Jun 4, 2022.
Random Link ¯\_(ツ)_/¯
May 12, 2022»Classes in C++ 15 min; updated May 12, 2022
Jun 4, 2022»Structures in C++ 1 min; updated Jun 4, 2022
Jun 4, 2022»Enumerations in C++ 7 min; updated Jun 4, 2022
Jun 4, 2022»Unions in C++ 2 min; updated Jun 4, 2022