Monthly Archives: January 2010

C++ Objects

While reading through chapter one of I learned what classes, objects, and member objects are. I also learned what inheritance and polymorphism are.

To solidify my learning of this chapter, I’ll summarize each of these concepts, then go back through the book and confirm what I wrote.

Classes are what are known as “types” of objects. A class is simply a group of objects which are related in some way, and programmers can define their own classes, as well as re-use pre-existing classes from other code.

Objects are what makes up a class. Similar objects are grouped together into classes, and usually perform very similar functions and share similar behaviors. Objects can be cloned with each clone performing independently of the other clones.

Member Objects:
Member objects are objects from different classes all piled together to construct a new type of class. This concept is known as composition. Composition should be looked to use when creating new classes over inheritance, because it will result in simpler and cleaner designs.

Inheritance is the act of taking a class and cloning it, then making necessary modifications to it.

Polymorphism is the idea of creating code to be executed without being dependent on specific data types. This is useful when you want to treat a variety of objects with the same function call. Although, this means that what code specifically executes won’t be determined until runtime. This is where late binding comes into play. Late binding allows the object’s properties to determine which actions to take during runtime when a particular function or command is called or sent. This will allow a single call to something like “draw” to be applicable to a wide range of objects of class “shape” without having to worry about which type of shape is being operated upon.

I plan to tomorrow take a look at chapter 2, which covers the implementation of objects in code.

Just got back from Winter Break. This alone should explain the long span between my two last posts.

In an attempt to keep this blog from becoming a diary, I want to jump straight back into my old daily routine of programming after homework//school.

I have some interesting links to share today. The first link is a link to a site in which I will be basing future studies on. I came across this site via a friend who is in their Junior year of college, and pursuing a degree in CS. He recommended that I read these books and follow along in them:

I will begin with the first book labeled as Volume 1 (filename TIC2Vone.pdf) found at this link:

Before I head into this book, I will also be studying this code:

That, is code that demonstrates tokenizing in C++ just like I did before, and it creates a square. The difference between this code and my code, is that my code sucks and this doesn’t. I will look over this code, understand it, then try to replicate something similar using it as a reference. Once I create a similar console program, I will then try to replicate the code once more without using the linked code as reference (unless I get stuck). This allows me to understand the code at a level of detail that is beneficial to me as I learn to use the C++ language.