How to learn C++ (and Windows development)

Every few months I get asked for book recommendations for learning the C++ programming language and then how to get started with Windows programming with C++. I don’t buy into the “C++ in 10 days” school of learning but rather advice readers to read books that will provide them with a good foundation.

Be warned: this is not for the faint of heart. If you’re looking for a gentle introduction to Windows programming then you should learn C#, but if you’re looking to “go deep” with Windows then you need to follow the C++ track, even if you eventually migrate to C# for some of your application development needs.

Here is what I recommend.

Start by working through The C++ Programming Language (3rd edition or special edition) by Bjarne Stroustrup, the creator of C++. This book will teach you what is generally referred to as Standard C++ and should apply to any C++ compiler on any platform.

The next step is to learn the fundamental building blocks of Windows applications. I’m talking about processes, threads, memory management and dynamic link libraries. Work through Programming Applications for Windows (4th edition; previously called Advanced Windows) by Jeffrey Richter. Unfortunately it appears to be out of print. There is always the Windows SDK to fall back on.

To build rich user interfaces I suggest you pick up a copy of Programming Windows (5th edition) by Charles Petzold. I honestly haven’t spent that much time with this book as I prefer to dig into the Windows SDK directly but this book is very well regarded and covers the essentials of windows and messages, basic graphics programming, keyboard and mouse input, etc. I also have to mention Programming Windows with MFC (2nd edition) by Jeff Prosise as it is a fantastic book and really helped me when I first started programming (with the 1st edition). I cannot however recommend MFC for those that are starting out as I consider it a legacy library. ATL combined with WTL provide a much more compelling solution for C++ programmers targeting the Windows operating system.

The .NET Framework may completely replace COM in the long run but COM is still very much alive today and must be understood if you want to take advantage of all corners of the Windows SDK. Essential COM by Don Box is all you need. This book is every bit as relevant today as when it was first released in the NT 4 era. To get up to speed on subsequent advances to COM you simply need to read the articles Don published in MSJ and MSDN Magazine since then.

The final book you need to read before we turn our attention to managed code is Programming Windows Security by Keith Brown. This book will help you to understand what principals and authorities are, how principals are authenticated, how access is enforced (authorization) and how authentication is achieved on a Windows network. This is essential information for any Windows developer.

The .NET Framework is the next (last?) major runtime you need to internalize. CLR via C# (2nd edition) by Jeffrey Richter is all you need here. There are some other good .NET books but this one will not only introduce you to C# but give you a good understanding of the Common Language Runtime and the .NET Framework.

In some ways the .NET Framework represents the future of development on Windows and C++ is ideally suited to get you there. I wrote one of the first articles on C++/CLI before the compiler even knew how to deal with it but if you really want to dig into C++/CLI and you should pick up a copy of C++/CLI: The Visual C++ Language for .NET by Gordon Hogenson.

There are many more books that I would recommend but the ones I mentioned thus far should give you a great start. Hope that helps!

© 2007 Kenny Kerr

9 Comments

  • A far superior C++/CLI book is "Expert C++ CLI - .NET for Visual C++ Programmers" by Marcus Heege

  • Grant: thanks for the suggestion. I haven’t come across that one before.

  • EN: I don’t believe you need to learn C first. As Stroustrup puts it, the common subset of C and C++ is easier to learn than C. Also, the Windows SDK has long been tailored toward C++ even though it continues to support C compilers. If you really want to learn C independent of C++ then you should read “The C Programming Language” by Kernighan and Ritchie but I would not advise this path.

  • I'd agree that you don't need to know C before you dive into C++. It helps but you can do without it. I also agree that Stroustrup's book is the best. I've recently gotten into more C++ development and I've found it to be absolutely invaluable.

  • I completely disagree on almost ALL parts of your list, first of all you fail to mention Accelerated C++ which is THE beginners book about C++ and you fail to mention Windows API by Mr. Petzold (a colleague of yours, though you have another book the Window API is THE bible regarding Windows development in C/C++ but DON'T learn Mr. Petzolds C++ habits! He don't KNOW C++...!)

    Another thing is that you mention a LOT of MFC books... MFC stinks, it always has done and it always will do. In fact MFC is probably THE worst API both to learn AND to use afterwards. Use Qt, SmartWin++, or Windows API directly... Or even WTL would be a better choice than MFC...!
    And Inside COM is FAR better than Essential COM and where's Exceptional C++, and all of those guys' books?
    About the ONLY thing I agree with you on apart from that one book by Petzold which I haven't read is the choice of Mr. Richter which is an AWESOME Windows internals dude...

    Though the C++ Programming Language IS good for reference causes, but DON'T START with that book. It'll kill your interest in the programming language...

    * Accelerated C++
    * Windows API (Petzold)
    * Advanced Windows Programming (out of print, still brilliant reading, Richter)
    * Inside COM
    ...and keep C++ the Programming Language for references...

    That's about the only really cost affording way to learn C++ the right way... ;)

    .t

  • Opps...!
    Sorry (about the MFC thing) I was probably too fast on the trigger when I noticed the MFC parts... ;)
    My bad, Sorry...! :)

    Anyway, you're completely right and it IS in fact possible to learn C++ by reading Bjarne's book, but I don't even think Bjarne HIMSELF is recommending that path...

    The definitive most cost efficient way to learn C++ is by picking up Accelerated C++ and start with that one...

    That way you won't have to DE-learn everything you've learned SO far when you dive into the STL and the other parts of the "advanced topics"... (which actually in fact are NEWBIE topics...)

    don't know how many different versions if std::string I've seen in my life, including CString, and they ALWAYS do more harm then good, e.g;
    CString x;
    delete x;

    Actually COMPILES...!
    Due to implicit conversions which is a BAD thing...!
    (that sample is also a nail in MFC's coffin btw...;)

    C++ is a marvelous language for doing some stuff which is more or less impossible to do in Managed environments and I am sorry if I was "fanatical" I just won't do un-just for the language by viewing something I saw as a list that'll kill interest in it or create developers that'll create heap loss every time they come close to their keyboard... ;)

    .t

  • Thomas: no worries. If you follow my blog and articles you should know I love C++. I even have a new C++ column starting this month in MSDN Magazine!

    I’ve heard good things about "Accelerated C++" and I’ll check it out when I get a chance. Thanks for the suggestion!

  • Great :)
    Accelerated makes the most complex programming language into a kindergarten lecture in fact... :)
    I think the book is no more than a couple of hundred of lines either, and it's cheap too I think...

    When I discovered this book I became "religious"... ;)

    It's one of the 7-9 books in the "Bjarne Recommends" series too...
    The only "beginner book" in that series too...


    .t

  • Hi Kenny.

    I have been trying to get a concrete answer about the future of C++ and Windows for a long time. Obviously C++ is still around in the Windows world, however, how much longer can COM really last? I think it is a poor investment of time for anyone new to start learning COM, from what I read from MS blogs, etc.

    I remember one time reading that the newer Windows OS will be all managed, *except* drivers and kernel. Therefore , native C++ would have to be wrapped by managed code to be able to run. Kinda of the opposite of today's C# being unwrapped down to native cli code. Is that true? I wish the direction would be more clearly defined. But as for COM I think its the consensus that it is dying off, and for some the sooner the better (no offense if your an IDL hacker).

    Best Regards.

Comments have been disabled for this content.