Using CodeBlocks 10.05 – Part 5

This post begins with the code found in Book IV Chapter 3 (found in \Author\BookIV\Chapter03) of my book,  C++ All-In-One Desk Reference For Dummies. I’ve been testing my code for use with CodeBlocks 10.05 continues. I introduced this new version in Using CodeBlocks 10.05 – Part 1, where I discussed the general look of the new version.

The example on page 456 (example Constructor04) is supposed to fail. It’s an example of what happens when you add a specific constructor to a class without also defining a default constructor. CodeBlocks 10.05 fails in the same way that its predecessor does. However, the order of the candidates may differthe Simple::Simple(int) version may appear first. I’ve pointed out a few other error message changes in other posts (you can see the entire list of posts for this book in the Category Archive for C++ All-in-One for Dummies).

Otherwise, all of the other examples in Book IV Chapter 3 should work as described in the book. Since there was little to talk about in Book IV Chapter 3, let’s also discuss Book IV Chapter 4.

The example that begins on page 482 (example OverridingDerived, found in \Author\BookIV\Chapter04) of the book compiles with three warning messages in CodeBlocks 10.05 as shown here:


C:\Author\BookIV\Chapter04\OverridingDerived\main.cpp: In constructor ‘Printer::Printer(std::string, Printer::PrinterType, int, int)’:

C:\Author\BookIV\Chapter04\OverridingDerived\main.cpp:19: warning: ‘Printer::Type’ will be initialized after

C:\Author\BookIV\Chapter04\OverridingDerived\main.cpp:22: warning:   base ‘Peripheral’

C:\Author\BookIV\Chapter04\OverridingDerived\main.cpp:20: warning:   when initialized here

Linking console executable: bin\Debug\OverridingDerived.exe
Output size is 1000.61 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 3 warnings

CodeBlocks 10.05 performs some additional checks that CodeBlocks 8.02 didn’t, so it will catch problems like the one shown in this listing. The example still works as described in the book. To get rid of the warning messages, you need to change the order of inheritance for the Printer class as shown here:

class Printer : public Peripheral {
    enum PrinterType {laser, inkjet};
    PrinterType Type;
    Printer(string aname, PrinterType atype, int aprice,
        int aserial) :
        Peripheral(aname, aprice, aserial), Type(atype) {}

The idea is to ensure initialization takes place in the correct order. Even though the initialization order doesn’t make a difference in this example, it could in code you write. Notice that Type(atype) now appears after Peripheral(aname, aprice, aserial), which provides the correct initialization order.

In the next post I’ll start with Book IV Chapter 5. In the meantime, let me know if you have any questions about the CodeBlocks 10.05 updates for this book at


Author: John

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 99 books and over 600 articles to date. The topics range from networking to artificial intelligence and from database management to heads-down programming. Some of his current books include a Web security book, discussions of how to manage big data using data science, a Windows command -line reference, and a book that shows how to build your own custom PC. His technical editing skills have helped over more than 67 authors refine the content of their manuscripts. John has provided technical editing services to both Data Based Advisor and Coast Compute magazines. He has also contributed articles to magazines such as Software Quality Connection, DevSource, InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software Test and Performance, and Visual Basic Developer. Be sure to read John’s blog at When John isn’t working at the computer, you can find him outside in the garden, cutting wood, or generally enjoying nature. John also likes making wine and knitting. When not occupied with anything else, he makes glycerin soap and candles, which comes in handy for gift baskets. You can reach John on the Internet at John is also setting up a website at Feel free to take a look and make suggestions on how he can improve it.