[prog] C++

Sue Stones suzo at spin.net.au
Thu Mar 4 15:41:26 EST 2004


On Thu, 4 Mar 2004 02:07 pm, wolf wrote:
> Hi,
>
> I trying to work on a sample C++ question but I'm having trouble
> getting started, I was
> wondering if anyone might be able to break this into pseudo code (I
> think that's
> what it's called when you just write out the steps in plain english?).
> No actual
> C++ code, I tend to have trouble getting started with the questions.

My understanding of the term psudo-code is that it is part way between english 
and code.  Someeimes its almost code, but its not intended to compile or be 
correct syntax, it may even be written in terms of different programming 
languages.  But the term may be broader than I understand.  Anyway I get what 
you are asking.

I have only done a little C++, unfortuanatly my attempts to learn it got 
squeezed out.  But I will answer your question form what I know and if thats 
not enough I am sure someone who understands more C++ can give further hints.

> write a program to track a music cd library, allow the user to enter
> cds. Each item
> should include the artist, album title, year and genre. All records
> should be
> displayed in order by artist. Design this using a class and represent
> each cd
> as an object of that class ( This is the part that is really confusing
> me). Store the
> data in a text file so it can be retrieved and viewed.

The idea here is to create a class from which you will create objects that 
represent each CD.  Inside this class it will have fields for all the pieces 
of data mentioned above, as well as functions that initialise variables, 
change variable, and allow you to read variables.  Something like this

class CD{
	 char *artist;
	 char *album title;
	 char *year;
	 char *genre

	CD() {initialise CD}
	void changeGenre() {}
	char *getCDdetails() {}
}

You will also need some static program to manage the CD, create them, ahange 
them, search for them, print them out etc.

> Since I use OSX I was sort of following itunes as an example, I have my
> cds listed
> in a database in mysql, but I don't know if you can connect to that
> with C++?

This may well be possible but isn't a basic C++ action.  If you are learing a 
language you would normally keep the data in something like a text file.  The 
program then load the info into memory for use, creating objects and acting 
on those objects as it proceddes.

I don't know anything about working with mysql from C++, perhaps someone else 
can answer this.

> Any ideas/suggestions would be appreciated : )

Hopefully i have helped a bit.  Ask more questions if it still not clear.

sue


More information about the Programming mailing list