Journal Articles

CVu Journal Vol 15, #3 - Jun 2003 + Programming Topics
Browse in : All > Journals > CVu > 153 (14)
All > Topics > Programming (877)
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: Learning C++: A Student's Perspective

Author: Administrator

Date: 03 June 2003 13:15:58 +01:00 or Tue, 03 June 2003 13:15:58 +01:00

Summary: 

Body: 

Since leaving university I have been presented with some interesting challenges: up to now the most rewarding was embedded C. I have been on a steep learning curve since starting that project and I very much wanted to maintain it. Before starting my latest project my C++ was at best limited to C++ style C and maybe using a few MFC classes scattered here and there.

I had expressed an interest in learning C++ to my colleagues. With some advice I decided I would make a start in my spare time. However I got a lucky break when I was given a C++ project. So I started with the advice given to me by my company mentor which was to read "Accelerated C++: Practical Programming by Example" by Koenig and Moo. My mentor also advised me to purchase other books that included "The C++ Programming Language" by Bjarne Stroustrup and the "Effective" series by Scott Meyers.

Before I had ever really gotten into C++ I was under the illusion that C++ was a difficult language which would take a great amount of time to learn. However as soon as I started to read Koenig & Moo these ideas where shattered. I had always believed C++ was an extension of C. I was simply wrong! I have since come to realise that C++, although based on C, is a language in its own right.

My first great revelation came as I read about vectors. I realised that this was a language which gave the flexibility I sometimes wanted or needed by encapsulating everything in a set of standard classes. Indeed I saw that C++ was a very good language.

So how did I do? Well let's start with the standard library, I had no idea that the standard library even existed let along the containers and algorithms that it contained. I found everything simply fitted in to place - although sometimes with a bit of a push! I was learning more about the language and was really getting to grips with it. However I had only copied a few of the examples from the book. I had yet to write any code of my own. One of the greatest things that the Koenig & Moo book gave me was the confidence to write the code which I was to produce.

I had written some classes before this project but never before with the kind of understanding I was starting to develop. The first code I was going to write was some classes which would be the main base for the first part of the software. I used many of the new containers and techniques I had learned. Indeed things were going very well and there were parts of the language I was really starting to like, such as variable references.

My first real challenge came when I wanted to remove elements from a list. My first attempt ended with me using an iterator in a for loop and removing the elements that matched the element which I wanted to remove. The only problem with this is that the iterator would then be incremented after the remove and meant that I missed elements. The answer was to use the list container's version of remove_if. My mentor told me I needed to write a functor predicate class. My response was quite clear. And one of them is...?

It was time to make my first use of Stroustrup's book. I looked up the information in the index and then I began to understand. After reading the book I wrote the class. It worked and I was very pleased with myself. Well since then I have used this feature a few times. I was also very impressed with the book as well.

So how did I come to join ACCU? Well that was at the recommendation of my mentor who showed me the site and lent me some of the magazines. I had a look through them and was impressed. I quickly realised that there are plenty of books on C++ and some of them are rubbish, but ACCU did book reviews so I could weed out the rubbish and pick the roses. In addition to this there were articles from which in time I could start learning more.

I wanted to write this article to show anyone like me, who happens to know someone with a copy of C Vu that beginning on the path to C++ enlightenment is not as difficult as it may first seem. Indeed with the right tools the path can be made easier.

So now I am 2 months in to C++ and I still have a lot to learn about the language and the use of the standard library. I have joined the accu-mentored-developers project "Begin C++". The aim of this was to concrete my current knowledge of the language and to complete the exercises in the book itself. Once that is finished then I move on to the Effective books nd in time more books. For now the road is long, but instead of walking I now have a car.

I will leave you with a final thought. C++ is a full and rich language which can be challenging and rewarding but most of all the best reward is starting down the path of learning the language and although that path never ends it will be a fantastic voyage.

Notes: 

More fields may be available via dynamicdata ..