i am trying to implement a database of books and i am have to use linked lists and possibly dynamic arrays for the first time so i am a bit confused..i just wanted to know if this is how i should b going about my constructors and if theres anything i should add or help me with..thanks

#include "library.h"
#include <iostream>
#include <string>
#include <cassert>
using namespace std;

Library::Library() //Creates an empty library without books and without authors.
{
   first = NULL;            
   last = NULL;
   count = 0;
}

Library::~Library() //Destructor
{
                         
}

void Library::add(string title, string authors[], int nAuthors) // Add a book
{
                   
}

void Library::print() const  // Print the list of all books ordered by book title.
{
     bookType *current;

	current = first;
	
	while (current != NULL)
	{
	   cout << current->info << " ";
	   current = current->link;
	}
     
}

void Library::printByAuthor(string author) const //Print the list of books of a given author, ordered by book title.
{
     
}

im not allowed to use stl..i have to use pointer structures (dynamic arrays and/or linked lists)

You already included namespace std...


As far as i remember from school you have to implement something like this:

struct ListElement
{
    int nSomeData;
    ListElement *previous, *next;
}

Then make functions like add(), delete(), etc...
You can close all these into class.

This article has been dead for over six months. Start a new discussion instead.