I keep getting the following error:
g++ SortedList.cpp
SortedList.cpp:260: error: expected constructor, destructor, or type
conversion before '*' token
SortedList.cpp:260: error: expected `,' or `;' before '*' token
Line # 260 is ListNode *SortedList::copyList( ListNode *L ) {
towards the end of the .cpp file.
I have just put stubs in fr the code that I know works for readability
purposes. here is my code:
#ifndef SORTEDLIST_H
#define SORTEDLIST_H
#include "Student.h"
class SortedList {
public:
SortedList();
// Constructs an empty list.
SortedList(const SortedList &SL);
//Copy Constructor
~SortedList();
//Destructor
SortedList & operator=(const SortedList &SL);
//operator equals
bool insert(Student *s);
Student *find(int studentID);
Student *remove(int studentID);
void print() const;
private:
struct ListNode {
Student *student;
ListNode *next;
};
ListNode *head; // pointer to first node in the list
static void freeList(ListNode *L);
static ListNode *copyList(ListNode *L);
};
#endif
----------------------------------------------------------
SortedList.cpp
----------------------------------------------------
#include <iostream>
#include "Student.h"
#include "SortedList.h"
using namespace std;
/* Constructs an empty list
*/
SortedList::SortedList() {
head = NULL;
}
SortedList::SortedList(const SortedList &SL) {
}
SortedList::~SortedList() {
}
SortedList & SortedList::operator=(const SortedList &SL) {
}
bool SortedList::insert(Student *s) {
}
Student *SortedList::find(int studentID) {
}
Student *SortedList::remove(int studentID) {
}
void SortedList::print() const {
}
void SortedList::freeList(ListNode *L) {
}
ListNode *SortedList::copyList( ListNode *L ) {
//create the node that is being copied to
ListNode *toReturn = new ListNode();
//if this is the last node in list, copy and return
if( L->next == NULL ) {
toReturn->student = new Student( L->next );
//else call the copy on the child of this node and
//copy the student to the linked list
} else {
toReturn->next = copyList( L->next );
toReturn->student = new Student( L->student );
}
return toReturn;
}