Home Catalog Evaluate Download

CPPIDE: An IDE for C++

The third component of the computer programming curriculum teaches you how to employ the C and C++ (pronounced "C plus plus") languages to construct both console-mode (i.e., textual) and true Windows programs (i.e., offering a graphical user interface).

There are 5 computer programming languages that are dominant today: Assembly, Visual Basic, Java, C, and C++. Assembly language is taught in the second component of this Computer Science Lab curriculum (all 3 components are distributed on the same CD-ROM). Visual Basic is rarely used for teaching because it is a proprietary technology from a single company (you know who). The Java language is often employed for teaching because you can obtain free tools from Sun and other companies. However this language runs too slowly to be appropriate for computer games, which is one reason many people are interested in learning about computer programming. I chose to teach the C and C++ languages because they can easily be taught simultaneously since C++ is a superset of the C language. And as a nice side benefit, 90% of what you learn in an introductory course such as this applies to Java as well since all 3 languages employ the same syntax. C++ is generally recognized as the most powerful high-level language in wide use today.

As in the previous sections of the Computer Science Lab curriculum, you get a complete integrated development environment (IDE) for the C and C++ languages. This programming environment includes a source code editor, compiler, and debugger. The editor is the Scintilla text editor which is an open-source component that offers many nice features such as automatic syntax color coding which helps your brain visualize the structure of your programs. The compiler is the Gnu compiler. The Gnu project is the most prolific originator of free (open-source) software and their C/C++ compiler is their crowning achievement (the same compiler can handle either language). The debugger is the Gnu GDB debugger.

The Gnu tools are console-mode programs intended for use on a UNIX computer. Fortunately, the MinGW ("Minimalist Gnu for Windows") project ports this software to the Microsoft Windows platform.

My contribution was to embed these console-mode utilities inside a standard Windows look-and-feel. The result is CPPIDE: a C++ IDE that closely mimics Microsoft's Visual C++ IDE . A screen capture of CPPIDE while it is being used to compose a program is shown below:

A typical view of CPPIDE while it is being used to debug a program is shown below:

Note especially the changes seen in the toolbar between these last two photos. CPPIDE gives you pretty much the same capability to debug your programs as is available with Microsoft's Visual C++ compiler which Microsoft sells for $100. CPPIDE and Visual C++ employ the same toolbar buttons for the standard debugging operations of Step Into, Step Into N, Step Over, Step Out, Run To Cursor, Restart, Add Breakpoint, Show Call Stack, etc. CPPIDE also offers many of the source code editor features of Visual C++ such as syntax color coding, brace matching, preprocessor conditional matching, a find tool on the toolbar, etc. CPPIDE and Visual C++ share the same basic screen layout where the project files are listed on the left, the source code is edited on the right, and the compiler and debugger messages are displayed at the bottom. Just as with Visual C++, CPPIDE offers splitter bars that allow you to adjust the relative screen areas used for these 3 panes.

Besides the integrated development environment, I also provide a book's worth (93,000 words) of on-line Help documentation that teaches you the C and C++ languages by walking you through 42 fully-explained example programs. Both console-mode (i.e., textual user interface) and Windows (i.e., graphical user interface) programs are demonstrated. A C++ class library insulates you from the daunting complexity of Windows programming (the standard reference book on Windows programming -- Charles Petzold's Programming Windows 5th Edition -- runs to 1450 pages!). This complete package gives you the power to create, edit, compile, run, and debug true Windows programs of your own creation, written in either the C or C++ language.

While working through the example programs, we revisit the scrolling electronic signboard, the robotic mouse in a maze, and the audio peak detector projects that we studied with the 8051 microprocessor in order to see how these programs look in a high-level language. A screen-shot of the maze program is shown below:

Another one of the example programs is a Breakout style game that you get to help construct. You are given a program that is mostly finished except for the annoying fact that the ball passes right through the paddle, the walls, and the blocks. It is your assignment to supply the code that detects collisions between these objects and causes the ball to rebound (of course, I provide a solution in case you get stuck). This game is shown in operation below:

Besides helping with the coding for the Breakout game, you also have the opportunity to customize its sound effects and even to provide original artwork for the ball sprite.

In the prior screen capture that shows the Breakout example program, you can observe that the window has been divided into 2 panes: one which displays text and one which hosts the game board. These two child windows are instances of the cEditBox and cBreakout classes respectively. The cEditBox class encapsulates the exact functionality of Microsoft's Notepad word processor in a component that can easily be re-used in other programs, where it can be assigned an arbitrary portion of the screen real estate. Besides the cEditBox and cBreakout classes, the C++ class framework that I provide with CPPIDE offers 15 other classes that encapsulate all of the complexities of child windows. For example, there is a cBitmap class that can display the picture from any .BMP file. There is a cAudioCD class that can play the music on any audio CD. There is a cMovie class that can play the movie in any .AVI file. There is a cWavePlayer class that can play the song in any .WAV file. There is also a cToolBar class which controls the toolbar and a cStatusBar class which controls the status bar.

Thanks to these re-usable child window components it becomes easy to construct the top-level window for a new program. So easy in fact, that CPPIDE offers a New Project Wizard that can assemble a new custom program that will compile and execute even before you have written a single line of code. Of course, to finish this new program you do need to write some code to customize the code provided by the wizard, but this is still a great productivity enhancer.

This same New Project Wizard also walks you through the steps of creating a brand new child window class that can then be used as a component in future programs. As an example of this process, I show you how to componentize the digital clock that is demonstrated in one of the example programs from the Petzold book. Thanks to the code provided by the New Project Wizard, you end up typing fewer statements than were in Petzold's original program yet you arrive at something far more valuable: a reusable child window component.

The programs you will write are standard Windows programs: you will be able to distribute the executable (.EXE) files you create to your friends who can run them on their computers. If you would like to see what a very simple C++ program looks like, click here.

The Computer Science Lab curriculum is unique in that it teaches the C and C++ languages while employing true Windows programs. Most C or C++ textbooks demonstrate only console-mode programs. And most books that teach graphical user interface programming assume you are already fluent with C or C++. Therefore, I have to separately list those resources that you can employ to advance your knowledge on these 2 fronts once you have completed the 93,000+ word Computer Science Lab curriculum.

You can find numerous C or C++ programming books in your local library. Many programming books come with a CD-ROM to make it easier for you to experiment with the example programs. Other authors provide a web site where you can download the source code discussed in that book. The sample code shown in these books can be compiled and executed from CPPIDE. To accomplish this you merely need to create a project (.PRJ) file and a makefile (.MAK file) for each program (a similar amount of infrastructure is required in order to bring a program into any of the other commercial IDE's such as Microsoft's Visual C++ IDE). CPPIDE's New Project Wizard automates this process.

Even though it only takes a minute to set up a CPPIDE project for a new program, this can get tedious when you need to construct projects for hundreds of example programs. Therefore the Computer Science Lab CD-ROM already includes the infrastructure needed for a large number of excellent example programs that originate in other author's books.

The sales statistics available from the Amazon on-line bookstore (www.amazon.com) document which C++ programming books are best sellers. Two such books stand out: C++ How To Program by Deitel and Deitel and Thinking In C++ by Bruce Eckel. The Computer Science Lab CD-ROM includes the project and makefiles for the 754 example programs illustrated in these two books.

Bruce Eckel makes electronic versions of his books, and their source code, freely available even though they are published works that you can find being sold in bookstores (as I said, these books are best sellers). Bruce Eckel has allowed me to include his C++ book and all 479 of his example programs on the Computer Science Lab CD-ROM. You can read more about the Eckel book here.

The Deitel and Deitel book is widely used as a college textbook. The text itself must be purchased, but the source code can be freely downloaded from the Deitel and Deitel web site. The Computer Science Lab CD-ROM includes the project and makefiles for all 275 of the example programs illustrated in this book. You can read more about the Deitel and Deitel book here.

Another popular C++ book is Sams Teach Yourself C++ In 21 Days by Jesse Liberty. I can't recommend this book as heartily as the prior books, but I again provide the project and makefiles for all 179 of the example programs demonstrated in this book. You can read more about the Sams book here.

Unquestionably, the best reference book for learning about Windows programming is Charles Petzold's Programming Windows Fifth Edition. This book includes 145 example programs which each serve to demonstrate a particular feature of the Windows user interface, such as the menu or the toolbar or the combo box. The only way to get the source code demonstrated in this book is from the CD-ROM that comes with the book. Mr. Petzold anticipated that you would buy Microsoft's compiler in order to compile these 145 example programs. But you can avoid that $100 expense because I have again provided the infrastructure that allows you to compile, execute, and debug these programs from within CPPIDE. Details on how to accomplish this are provided here.

Return to the Catalog of Programs