Thinking in Objects

Traditional procedural programming focuses on actions – functions. Object oriented programming focuses on data (objects) and the operations on objects. You want to look at items that you will be coding, and think, what makes this information up? and, What things can it do, and/or be done to it? Objects in the physical realm are…

Arrays of C++ Objects

We’ve talked about arrays and objects before, but now we’re going to look at an array of objects. Consider a situation where you had a class called Student. While you would often need to work with a singular student, you could very likely also need to have multiple students, for example, if you were talking…

The String Class

In C++ there are two ways to process strings. C-Strings which are an array of characters terminated by a null character, or the C++ style string object. The string class hides the details of how the string is stored from the user – remember one of the tasks of a class is to abstract the…

Data Field Encapsulation

Previously we looked at a class Circle, which had a property radius that was publicly available. That means that any other class, or your main program could change that value. This is a problem for two reasons: First, that data could be tampered with. Another function, class, etc could directly access the variable and change…