Re: concepts help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"rodchar" <rodchar@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:408D45C6-5D0B-4D9E-AD0E-F8DDCB6F360D@xxxxxxxxxxxxxxxx

i'm working on a windows programming tutorial using C++ and there's a
section about wrapper classes with the following example:

class Integer {
public:
Integer();
Integer(int initialValue);
virtual ~Integer();
private:
int data;
}


What would be the benefit of doing something like this? And is the example
above still used today?

This actual class might not be a lot of use in practice. However it forms a self-contained example of a class which doesn't require a lot of specialist knowledge in advance in order to understand it. So its utility will be in exactly what C++ concepts you want to illustrate with it. Above you have constructor, virtual destructor, public, private, all of which could be discussed. Other useful additions would be assorted operators as well as concepts like const.

BTW - the virtual destructor indicates that you expect to derive something from this class. That would make a lot more sense if the data member were protected instead of private, or if some get and set methods were provided.

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm

.



Relevant Pages