/Programming-Principles-and-Practice-Using-Cpp

My reading of Programming: Principles and Practices using C++ (2nd ed) by Bjarne Stroustrup

Primary LanguageC++

Stroustrup, Bjarne. Programming: Principles and Practice Using C++.

Where to buy this book

Link to PPP on Amazon.

Why

I created this repository to share my solutions for the try its, review questions, drills, and exercises while working my way through Stroustrup, Bjarne. Programming: Principles and Practice Using C++ . Pearson Education. Kindle Edition.

Useful tools

  • Microsoft Visual Studio Community is what I will be using for the exercises from this book.
  • vcpkg is a free C/C++ package manager for acquiring and managing libraries.
  • MinGW variant distribution that supports the latest GNU GCC compiler also is packaged with Boost and other neat libraries. Also, the distribution comes with the latest GNU Make program so you can create custom command line compiles from C++ files created via your favorite editor.

Notes

I will be using Microsoft Visual Studio Community to go through this book with compiler set to C++20. I created a solution folder named PPP and added each section as projects. In the solution properties I selected Current selection under Common Properties/Startup Project. Play with the selections and pick what you prefer.
Project Selection

If the sections contain multiple files with a main function just right click on the file and select Exclude from Project solution explorer tab. Can always go back and add files back by selecting Include in Project. In the Solution Explorer tab you can select view all files to see all the included and excluded files. if have files with 2 main functions will get this error fatal error LNK1169: one or more multiply defined symbols found
View All

I will be using added statements to pause the program to see the program output ex: std::cin.get(); //wait for a character to be entered or can use another method backed into visual studio by checking if not already enabled can select Tools/Options/Debugging/General
Pause Option

Deviations / Status

If you're reading along you will notice I intentionally left out the header file mentioned in the book. Instead I created a section header file for each of the sections because in the book's presented header file the functions have been implemented into most modern compilers, plus I wanted some experience dealing with custom header files. If you want, you can get the header file from book's website www.stroustrup.com/Programming.
section 0 book organization stuff
section 1 general software history and things to think about
section 2 where coding exercises start. complete
section 3 complete
section 4 complete
section 5 complete
section 6 complete
section 7
Starting in this section, I will be using a general a header file in the project include folder for this section and the remaining sections.
Right or wrong, I removed the syncing of the cpp streams to the c streams by defining std::cin.sync_with_stdio(false). Normally all C++ streams have this set to true. This will provide better reliability into the cin.rdbuf()->in_avail() function. Seems to be compiler dependent on how count is reported if set to true. Again right or wrong I don't know but I needed to see if anything is in the cin.rdbuf, see ppp.h for additional details. Also set up namespace (ppp) for functions unique to this books exercises.
Exercises 9, 10 and 11 are incomplete.
section 9
Exercises 17 and 18 are incomplete.
section 11
Exercises are not completed.
section 12
For help using the FLTK library I'm using vcpkg C/C++ library manager.
See section_12.vcxproj to see how I set FLTK includes and libs files.
I have mine one folder up from my project root folder ($(SolutionDir)..\vcpkg\installed\x64-windows-static\include) this may vary depending on OS and other options, refer to vcpkg documentation
Before including classes needed for this section you can compile and run the fltk_test_window.cpp file to check that you linked the libraries correctly.

I'm working my way through the classes used for this section. The files from the books website don't seem to work correctly. I'm currently debugging these files to get them to work, stay tuned.

section 13
section 14
section 15
section 16
section 17
section 18
section 19
section 20
section 21
section 22
section 23
section 24
section 25
section 26
section 27

Some web sites I found helpful

Disclaimer

I'm new at this so any suggestions or comments are appreciated.