Main Menu

Sponsored Links


Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next


C++ is generally considered an object-oriented programming (OOP) language, which means that it provides features that support object-oriented programming. So far, though, we have not taken advantage of the C++ features that support object-oriented programming (except using internal WCM objects). For the most part they provide an alternate syntax for doing things we have already done, but in many cases this alternate syntax is more concise and more accurately conveys the structure of the program.

The basic features of an object-oriented programming language include:

  1. Programs are made up of a collection of class definitions and function definitions, where most of the functions operate on specific kinds of classes (or, more specifical ly, instances of classes or objects).

  2. Each class definition corresponds to some concept and/or type of object in the real world, and the functions that operate on that structure correspond to the ways real-world objects interact.

  3. Each instance of a class (i.e., each object) has its own unique local data and capabilities that are not shared with other parts of the program.

  4. Classes are hierarchical and sub-classes inherit the properties of the parent class.

The above features, especially inheritance and protected data, will be discussed in the following sections. They are the key to implementing something called polymorphism. Polymorphism is a rather abstract concept and is difficult to define precisely – but “you know it when you see it.” Basically the concept is that each object is essentially complete in itself and can be used by other parts of the program without knowing the implementation details of the object itself. (You don’t have to know the details of the Boy class or the IhumanCharacterSideView parent class to tell a boy named Max to move to a specific point, for example.)

Polymorphism, as well as classes and objects, are not really necessary for small programs or such things as complex numerical computations or even some data base manipulations. After all, it took over thirty years from the first high level languages before OOP concepts started to emerge. Even now, C++ supports the older procedural features of its predecessor, C. Java, and to some extent C#, are regarded as more “pure” OOP languages. Java in particular is currently the preferred language for academic use (C# is fairly tightly tied to the Windows operating system and is not particularly portable). However C++ remains the preferred language in industry largely because of the amount of legacy code available and to a lesser extent because it will also run well on UNIX based systems – in fact its predecessor, C, was actually developed for use in developing UNIX.

So if it isn’t really necessary, why is OOP regarded as the preferred programming method (with very few exceptions) today. The answer is simple – over the last 50+ years, as computers have become more powerful and more memory has become available, program complexity has increased accordingly. Trying to keep track of all of the details of the entire program in one place becomes nearly impossible. More importantly, without OOP a change in some aspect of the computing environment, such as a new graphics card, would require massive reprogramming instead of modifications only to some members of the graphics interface class.

Classes vs. Objects

Most of the data types we have been working with represent a single value – an integer, a floating-point number, a boolean value, etc. With these familiar things, there is no confusion between a variable type (int or bool) and its current value (5 or true).

Internal WCM objects (Image, Text and characters) are different in the sense that they are made up of smaller pieces. They contain information about objects in a cartoon scene like their IDs, associated text strings or image URLs, parts and some other information.

W e may even want to create our own objects like these. Depending on what we are doing, we may want to treat an object as a single entity, or we may want to access its parts (or instance variables). This flexibility is useful.

The key concept here is to make class definition for the desired type of object or group of objects. The class is analogous to a variable type – for example we can define the class “Boy” and then use several different boy objects (say Max, Joe and Sam) in a scene. The specific objects are called instances (or instantiations) of the class “Boy” and can have different positions, scale factors, etc. This concept will be explored in later sections but first the basic principles involved will be illustrated by developing a simple (and somewhat artificial) class “Point” , which defines a class of objects in two dimensional space such as “Starting Point” and “End Point.”

Contents Previous Next

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi


Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat


Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.


Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal


read more news...