Pages

Thursday, 28 March 2024

Chapter 3 // Exercise 1, 2 - The C++ Programming Language

For this exercise I'm using Visual Studio Community 2022 and the header file std_lib_facilities:
https://github.com/l-paz91/TheCppProgrammingLanguage/blob/main/std_lib_facilities.h

The exercises can be found online and are not actually in the book:

Chapter 3 - A Tour of C++: Abstraction Mechanisms
Exercise 1
When first reading this chapter, keep a record of information that was new or surprising to you. Later, use that list to focus your further studies.

A concrete type means something that can be instantiated/created. Built-in is something directly supported by the language, therefore something like a Vector is a concrete but not built-in as it relies on the specific library you're using for it's definition. New comp sci words were learnt today.

Or built-in refers to primitive types, anything that becomes user-defined (even if it's using primitive types) becomes concrete but not built-in. This was actually quite confusing to wrap my head around.

Exercise 2
Give five examples of concrete types that are built-in types in C++. Give five examples of concrete types that are not built-in types in C++.

Concrete types that are built-in (no outside library/definitions needed):
1. Int
2. Double
3. Char
4. Bool
5. Float

Concrete types that are not built-in:
1. std::vector
2. std::string
3. enum
4. class/struct
5. std::list

No comments:

Post a Comment