473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

weird compiler error---HELP!

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;
}

Nov 3 '05 #1
2 1821
sarah wrote:
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:
[...]
ListNode *SortedList::copyList( ListNode *L ) {
You need to qualify the 'ListNode' at the beginning:

SortedList::ListNode *SortedList ...
[...]


V
Nov 3 '05 #2
many thanks!!

Nov 3 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: codymanix | last post by:
Hi, I had an error in my application and after lots of investigation it boiled down to this: public class C : System.Windows.Forms.Control { public int i; } C c = new C(); c.i.GetType(); ...
21
by: JKop | last post by:
Today I wrote a function that returned an "std::ostringstream" by value. I compiled it with G++. It was throwing exceptions at run-time and closing. So I look through the code, and I look...
2
by: Todd A. Anderson | last post by:
Hi...any help would be appreciated. Kind of a weird scenario but I have foo's that point to bars and whenever anybody tries to use a foo as a pointer I want it typed as a baz * and likewise if...
10
by: chris | last post by:
I'm not sure if this is a bug being caused by visual studio, or by the vb compiler itself. I have good size solution (33 projects) and am consistently having a problem with one project.. ...
18
by: John Rusk | last post by:
Hi, I have some weird compiler behaviour, so I'm hoping that one of the gurus here will be able to tell me whether or not it really is a compiler bug. In short, the compiler is saying that it...
6
by: jytylr | last post by:
I'm getting a compiler error that says "Cannot convert from int to int?". I have no idea what this means. Here's a screenshot: http://www.sendspace.com/file/6o20pn Any ideas?
3
by: Joe Van Dyk | last post by:
I'm compiling some code on a IRIX compiler (MIPSpro Compilers: Version 7.4.2m) with all warnings turned on, and I'm getting some of these warnings: cc-3649 CC: ERROR at end of source all...
9
by: fabio.bizzetti | last post by:
Hello all, I went across what seems possibly a bug of the compiler (VisualC 2005, just for the record) or a very strange and non-expected (by me at least) behaviour of the C++ ISO standard. Thus...
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.