template <class T>
class LinkedList1
{
private:
// Declare a structure
struct discList
{
T value;
struct discList *next; // To point to the next node
};
discList *head; // List head pointer
public:
// Default Constructor
LinkedList1()
{ head = NULL; }
// Destructor
~LinkedList1();
// Linked list operations
void appendNode(T);
void insertNode(T);
void deleteNode(T);
void displayList() const;
};
Would it be LinkedList1<DVD> dvd;? That is only using the class as a data type for the linked list.. How do I use the struct disc as the data type?
My instructions are to have a class with a struct that holds the length of the dvd and the name. Here are my instructions which is the same for the DVD..
The CD class will use a linked list to keep track of the titles of the songs on the CD; this will allow each CD to have a different number of songs. It should also maintain the length of each song, thus the class will use a structure which will have the song title and its length. Each song will be an instance of this structure and will be stored in the linked list.
You've defined disc as private, so only code in the DVD class can use it. If you want the type to be usable by other code, e.g. the code that's creating the linked list, then you'll need to expose it in the public interface.