0

I'm trying to make a program to allow me to enter information(mainly books) in to a sort of library. I read that <list> is an easy way to add things and sort them.

Also by use a hierarchy I can use my base class and just add on to each different type of item i wish to add. Is there a sample code or tutorial to help me with this?

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by jencas
0

What types of items do you want to be derivities of a base class? Such as books, movies, newspapers, broadway plays, etc. ?

<list> is similar to normal linked lists. <vector> is like an array. Which to use depends on what you want to do with them. And both are far superior to the C counterparts (linked lists and array).

0

i plan on doing

class Data
{
Title
Author
Publisher

}

class video :: class Data
{
Length
Genre
}

class video:: class magazine
{
Edition
Editor
}

0

as for the <list>

I plan on storing each of the books, movies and mags

I read up on it and its easier to use by using push. instead of having to set the space to null increasing it and what not

0

you might want to use a vector

vector<Data*> theList;
magazine* n = new magazine;
theList.push_back(n);
video* v = new video;
theList.push_back(v);

One problem in the above is you need some method to distinguish the class types when extracting them from the vector. Is theList[0] of class magazine or video? You might want an indicator (integer) in the base class.

0

theList[0] = data(a book)
theList[1] = video
theList[2] = mag

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.