I can't work around these errors. Can someone help me out?
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 3 error C2238: unexpected token(s) preceding ';'
Error 1 error C2143: syntax error : missing ';' before '<'
Code:
#pragma once
#ifndef RainfallList_H
#define RainfallList_H
#include "Rainfall.h"
#include <iostream>
using namespace std;
//*********************************************
// LinkedList class *
//*********************************************
template <class L>
class RainfallList:Rainfall
{
public:
RainfallList()
{
head = NULL; // Establishes empty linked list
}
~RainfallList();
// Linked list operations
void appendNode(L);
void insertNode(L);
void deleteNode(L);
void displayList() const;
private:
RainfallListNode<L> *head; // List head pointer
};
//*********************************************
// The ListNode class creates a type used to *
// store a node of the linked list. *
//*********************************************
template <class L>
class RainfallListNode
{
public:
L value; // Node value
RainfallListNode<L> *next; // Pointer to the next node
// Constructor
RainfallListNode(L nodeValue)
{
value = nodeValue;
next = NULL;
}
};
//***********************************************
// appendNode function adds the node to the end *
// list. It accepts an argument. *
//***********************************************
template <class L>
void RainfallList<L>::appendNode(L num)
{
List *newNode; // To point to a new node
List *nodePtr; // To move through the list
// Allocate a new node and store num there
newNode = new List;
newNode->value = num;
newNode->next = NULL;
// If there are no nodes in the list make
// newNode the first node
if (!head)
{
head = newNode;
}
else // Otherwise, insert newNode at end
{
// Intialize nodePtr to head of list
nodePtr = head;
// Find the last node in the list
while (nodePtr->next)
{
nodePtr = nodePtr->next;
}
// Insert newNode as the last node
nodePtr->next = newNode;
}
}
//***********************************************
// insertNode function inserts the node in *
// numerical order. It accepts an argument. *
//***********************************************
template <class L>
void RainfallList<L>::insertNode(L num)
{
List *newNode; // A new node
List *nodePtr; // To traverse the list
List *previousNode = NULL; // The previous node
// Allocate a new node and store num there
newNode = new List;
newNode->value = num;
// If there are no nodes in the list make
// newNode the first node
if (!head)
{
head = newNode;
newNode->next = NULL;
}
else // Otherwise, insert newNode
{
// Position nodePtr at the head of list
nodePtr = head;
// Initialize previousNode to NULL
previousNode = NULL;
// Skip all nodes whose value is less than num
while (nodePtr != NULL && nodePtr->value < num)
{
previousNode = nodePtr;
nodePtr = nodePtr->next;
}
// If the new node is to be the 1st in the list
// insert it before all other nodes
if (previousNode == NULL)
{
head = newNode;
newNode->next = nodePtr;
}
else // Otherwise insert after the previous node
{
previousNode->next = newNode;
newNode->next = nodePtr;
}
}
}
//***********************************************
// deleteNode function removes the node from the*
// list without breaking the links created by *
// the next pointers and removes the node from *
// memory. *
//***********************************************
template <class L>
void RainfallList<L>::deleteNode(L num)
{
List *nodePtr; // To traverse the list
List *previousNode; // To point to the previous node
// If the list is empty, do nothing
if (!head)
{
return;
}
// Determine if the first node is the one
if (head->value == num)
{
nodePtr = head->next;
delete head;
head = nodePtr;
}
else
{
// Intialize nodePtr to head of list
nodePtr = head;
// Skip all nodes whose value member is not
// equal to num
while (nodePtr != NULL && nodePtr->value != num)
{
previousNode = nodePtr;
nodePtr = nodePtr->next;
}
// If nodePtr is not at the end of the list, link
// the previous node to the node after nodePtr,
// the delete nodePtr
if (nodePtr)
{
previousNode->next = nodePtr->next;
delete nodePtr;
}
}
}
//***********************************************
// displayList shows the value stored in each *
// node of the linked list pointed to by head *
//***********************************************
template <class L>
void RainfallList<L>::displayList() const
{
List *nodePtr; // To move through the list
// Postion nodePtr at the head of the list
nodePtr = head;
// While nodePtr points to a node, traverse the list
while (nodePtr)
{
// Display the value in this node
cout << nodePtr->value << " ";
// Move to the next node
nodePtr = nodePtr->next;
}
}
//***********************************************
// Destructor function deletes every node in the*
// list. *
//***********************************************
template <class L>
RainfallList<L>::~RainfallList()
{
List *nodePtr; // To traverse the list
List *nextNode; // To point to the next node
// Position nodePtr at the head of the list
nodePtr = head;
// While nodePtr is not at the end of the list
while (nodePtr != NULL)
{
// Save a pointer to the next node
nextNode = nodePtr->next;
// Delete the current node
delete nodePtr;
// Position nodePtr at the next node
nodePtr = nextNode;
}
}
#endif