“My aim is not only to complete the assignment but to improve as a programmer. I know that if I got better with each assignment completed, one day I will be world class.”
“The Attention to details is what make a programmer.”
“The beginning is always hard, you have to use all your strength, all your mind and all your heart to move the project to a position that it makes sense. It’s like playing sudoku. The starting is always the hardest but once you reach the halfway point, the difficulty curve drop tremendously. Many people are turned off by the initial steep curve but once you climb over the peak the feeling is indescribable and the more times you overcome it, the easier the next climb is.“
“It sucks, It always sucks! The sooner you realized it, the better you feel. You just have to stick through it. And since it sucks, you might as well have fun doing it while it sucks.”
“Be world class in everything u do!”
Shallow Copy means that C++ copy each member of the class individual using assignment operator. When classes are simple this work very well. However to when designing class with dynamic allocated memory this will cause us a lot of problems because the standard assignment operator just copy the address of the pointer. It does not allocate any memory or copy any of the contents that is being point to.
The answer to the above problem is to do a deep copy on any pointer that is not null. A Deep copy duplicate the object or variable that is being point to so that the destination receives it’s own copy of the object. This way the destination can do whatever it wants with its local copy without affecting the object that it was copied from.
The rule of thumb is that whenever you have a dynamic allocated object, you need to write your own copy constructor, assignment constructor and destructor. If not the default copy constructor, assignment constructor and destructor will be good enough.