I have been reading a bit on when, and when not, to use classes. As an example, can someone advise me on the following.
Let's say I want to write a program that will tell me how long to go before a certain event, call it the 2010 soccer world cup. Would this need classes? If so, what classes would I set up?
The only time I don't use classes is when it's just for a helper function, eg. mathematical functions or generic algorithms. Some of these, if made more complex, could be converted into classes but it's not always necessary.
In your example, I'd use classes for the interface and probably a QDateTime class or something derived therefrom.
your 2010 program would need to hold data pertaining to your 2010 needs, say number of days, weeks, months, years. It would need specific functions to calculate these. These are your fields and methods. So you can have a 2010 class to deal with 2010 data. If you need a function to convert days to weeks, for instance, that can be made into a universal helper function - either make it public so that you include 2010 in other projects, make it static and just refer to it without instantiating a 2010 object or stick it in a helper class like MyHelperClass (this could lead to a jumble up too.) Classes should be loosely coupled with as tight cohesion as possible.
If you're going to write many 2010-related programs/versions, then you would want a template class to derive from. Then you start looking at abstract classes and interfaces (I'm not sure if C++ draws a distinction between the two) and use inheritance.
You can use design patterns when your 2010-class starts getting complex and you want to simplify maintenance. I must just say, from reading pretentious comments in the social forums, that design patterns are merely an aid to solving a type of problem and should not be over-used. It allows one to stand on the shoulders of giants when designing a complex solution and shouldn't make the solution unnecassarily complex.
Then you start looking at abstract classes and interfaces (I'm not sure if C++ draws a distinction between the two) and use inheritance.
Unlike Java, there is not distinction between the two. In fact, c++ allows you to hybridise the two concepts. You can have a complete class with data and methods except for a single pure virtual method and it would become abstract (this may sound odd but can be very useful). You can make the equivalent of a Java interface by creating a class definition with nothing but pure virtual functions.