Posts

Showing posts with the label tutorial

C++ Crash Course: Solution to Exercise 3-2.

Image
My solution to Exercise 3-2 from Part 1, Chapter 3 of C++ Crash Course. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/blob/master/P1C3/EXERCISES/3_2.cpp Youtube: C++ Crash Course: Solution to Exercise 3-2.

Using the Copy Assignment Operator to copy objects that have raw pointers.

Listen to this article: https://youtu.be/MdGPC9C5QEI According to cplusplus.com: "A copy constructor is a special constructor for a class/struct that is used to make a copy of an existing instance." The Implicit Copy Constructor      If a copy constructor is not declared, the compiler will use a default one implicitly. The default constructor performs a member-wise copy of the source object. This means that each member is initialized using the corresponding member of the initializer.     Problem: Raw pointers.      If the object contains raw pointers, a member-wise copy may not be appropriate for use. This can cause problems with dangling pointers, double frees, and other undefined behaviour resulting from destructing objects.     Solution: Deep copy.      We explicitly define our own copy constructor when we want to perform a deep copy. That is, instead of copying the pointer, our copy constructor will copy what the po...

CPP Crash Course Review: Overture to C Programmers, and Chapter 1.

A while back I wanted to review the book C++ Crash Course  as a way of making sure I had explored the various facets of C++, but was side-tracked with the learning of other programming languages such as Java . Now I have some time to review my knowledge of these languages, and I want to take this opportunity to refresh my memory of certain concepts, and perhaps even spend time delving into aspects of C++ that I never fully grasped. In my review of the Overture to C Programmers chapter, I did not find anything of of extreme interest. It was mostly a review of the basics of C++, however there were some very competent explanations of some concepts. Probably a bit too much detail if you are somebody already familiar with C, but for those who are new it may be worthwhile. Overall, Chapter 1 made me realize how easily I confuse C with C++ code. This is in part because most well-written C programs are valid C++ programs. Nothing new was learned, but at least I got a chance to set up my ...

My Python Notes.

Started learning Python recently by following this tutorial. Here is a link to my notes, which you may or may not find helpful if you are new to Python. The notes are based on the W3 Schools tutorial that I am doing, and I include my own notes and experiments along with them. https://github.com/pereiradaniel/w3_python/blob/master/notes.md