Category Archives: Code Snippets

A Slot Machine using ASCII Art

As explained in Chapter 12 of our book, Learning C++, the idea of this exercise is to develop a Las Vegas-style slot machine game. Slot machines allow the player to press a button and get 3 or more images. The … Continue reading

Posted in Code Snippets | Tagged , , , , , , , , | Leave a comment

Why do we need modules

I have been using C++ since 1996. Yes, C++ is an old language but I always found it the best language to u to achieve any goal, including goals that are typically associated with other languages. I use C++ for … Continue reading

Posted in Code Snippets | Tagged , , , , , , , , | Leave a comment

Handling Exceptions

An important part of the book Learning C++  exception handling, and especially exception handling in C++ 20. Here is an example: #include <strexcept> #include <iostream> class MyException : public std::runtime_error { public: MyException(const char* message) : std::runtime_error(message) {} /* a … Continue reading

Posted in Code Snippets | Leave a comment

Capitals

One of the code samples in my book Learning C++  is Capitals. The purpose of the code was to explain key terms in the C++ 20 Standard Library, along with a small twist. The program tells you the capital of … Continue reading

Posted in Code Snippets | Leave a comment