473,243 Members | 1,438 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,243 software developers and data experts.

Student requests help... expected `;' before '(' token

I am a student who is losing his mind.

The code below is a header file which has the line:

void ClearList(ListType *list);

which generates the following compile time errors:
variable or field `ClearList' declared void
expected `;' before '(' token

The first error makes no sense to me since it is OBVIOUS I set it to
return void (nothing). The second seems to imply that one of the lines
above is missing a ;

If I comment out the 'void ClearList...' the ; error goes away and it
will compile. This indicates that I am NOT missing a ; before the
declaration.

Can anyone wiser than me see the problem?? I have been looking at that
one line for an hour.

<code>
class JobCollection
{
public:

/************************************************** ****
Constructor

Inputs:
Outputs:

Notes: Creates a new empty linked list with no nodes.
************************************************** **********/
JobCollection();

/************************************************** ****************************
ClearList

Inputs: Pointer to a list
Outputs: None

Notes: Empties the list of all nodes.

************************************************** *****************************/
void ClearList(ListType *list);
typedef Job ListEntry;

typedef struct list_node_def
{
ListEntry data;
struct list_node_def *next;
}ListNode;

typedef struct listtype
{
int count;
ListNode *head;
}ListType;
private:

/************************************************** ****************************
CreateList

Inputs:
Outputs: None
Notes: Creates an empty linked list with no nodes

************************************************** ****************************/
void CreateList(ListType *list);

};
</code>

Oct 5 '06 #1
3 34429
sa***@murdocks.on.ca wrote:
I am a student who is losing his mind.

The code below is a header file which has the line:

void ClearList(ListType *list);

which generates the following compile time errors:
variable or field `ClearList' declared void
expected `;' before '(' token

The first error makes no sense to me since it is OBVIOUS I set it to
return void (nothing). The second seems to imply that one of the lines
above is missing a ;

If I comment out the 'void ClearList...' the ; error goes away and it
will compile. This indicates that I am NOT missing a ; before the
declaration.

Can anyone wiser than me see the problem?? I have been looking at that
one line for an hour.

<code>
class JobCollection
{
public:

/************************************************** ****
Constructor

Inputs:
Outputs:

Notes: Creates a new empty linked list with no nodes.
************************************************** **********/
JobCollection();

/************************************************** ****************************
ClearList

Inputs: Pointer to a list
Outputs: None

Notes: Empties the list of all nodes.

************************************************** *****************************/
void ClearList(ListType *list);
typedef Job ListEntry;

typedef struct list_node_def
{
ListEntry data;
struct list_node_def *next;
}ListNode;

typedef struct listtype
{
int count;
ListNode *head;
}ListType;
private:

/************************************************** ****************************
CreateList

Inputs:
Outputs: None
Notes: Creates an empty linked list with no nodes

************************************************** ****************************/
void CreateList(ListType *list);

};
</code>
class Job
{
/* contents of 'Job' ... */
};

class JobCollection
{
public:

JobCollection();

/* typedefs for structs are not req'd in C++ */
struct ListNode
{
/* Warning: 'Job' must have already been defined */
Job data;
JobCollection::ListNode * pNext;
};

struct ListType
{
int count;
JobCollection::ListNode * pHead;
};

void ClearList(JobCollection::ListType * pList);

private:

void CreateList(JobCollection::ListType * pList);

};
Oct 5 '06 #2
sa***@murdocks.on.ca wrote:
void ClearList(ListType *list);
typedef Job ListEntry;

typedef struct list_node_def
{
ListEntry data;
struct list_node_def *next;
}ListNode;

typedef struct listtype
{
int count;
ListNode *head;
}ListType;
ListType is declared _after_ the declaration for ClearList(). Therefore, the
compiler doesn't know about it when it is looking at ClearList(). Notice
how you are not getting the error for CreateList()? Putting the typedef for
ListType before the ClearList() declaration will correct the error.

Alvin
Oct 5 '06 #3

sa***@murdocks.on.ca wrote:
I am a student who is losing his mind.

The code below is a header file which has the line:

void ClearList(ListType *list);

which generates the following compile time errors:
variable or field `ClearList' declared void
expected `;' before '(' token

The first error makes no sense to me since it is OBVIOUS I set it to
return void (nothing). The second seems to imply that one of the lines
above is missing a ;

If I comment out the 'void ClearList...' the ; error goes away and it
will compile. This indicates that I am NOT missing a ; before the
declaration.

Can anyone wiser than me see the problem?? I have been looking at that
one line for an hour.
Your compiler is your friend, its telling you that that it recognizes
ClearList and a return type but that its unable to match a declaration
with whatever is between the parantheses (read between the lines).
ListType at that point was never declared. So the compiler proceeds by
ignoring everything else on that line. That ignoring is your hint to
the solution.

There is no requirement for the compiler to detect that ListType is an
undeclared variable, function or pointer or anything at all.
>
<code>
class JobCollection
{
public:

/************************************************** ****
Constructor

Inputs:
Outputs:

Notes: Creates a new empty linked list with no nodes.
************************************************** **********/
JobCollection();

/************************************************** ****************************
ClearList

Inputs: Pointer to a list
Outputs: None

Notes: Empties the list of all nodes.

************************************************** *****************************/
void ClearList(ListType *list);
typedef Job ListEntry;

typedef struct list_node_def
{
ListEntry data;
struct list_node_def *next;
}ListNode;

typedef struct listtype
{
int count;
ListNode *head;
}ListType;
private:

/************************************************** ****************************
CreateList

Inputs:
Outputs: None
Notes: Creates an empty linked list with no nodes

************************************************** ****************************/
void CreateList(ListType *list);

};
</code>
Oct 5 '06 #4

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

Similar topics

9
by: Billy Patton | last post by:
First, I'm not a student looking for help. Although there's nothing wrong with studens looking for help here. I'm learning c++ move further away from the perl wars here at work (my version is...
7
by: schdvir | last post by:
Hi I tried to compile a program and I got this error: tdagent.C: In constructor `tdagent::tdagent(simple_env*)': tdagent.C:13: error: no matching function for call to `actor::actor()'...
6
by: SteelSide | last post by:
Ive searched and searched,but havent been able to get it to work. ----------------- #include <iostream> using namespace std; std::string tempHostNameStr = "s1e2.hidden.thingy.org"; char...
5
by: sandy | last post by:
I am a student with an assignement due tomorrow. I am to write a sort of a memory manager, I don't want to go into all of the details (it's long). I have the following header file for my memory...
0
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
2
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
1
by: mshroom12 | last post by:
Hello to all. I am having difficulty trying to do this Java project using Eclipse. The following is what I have to do. Election Day It's almost election day and the election officials need a...
2
by: kya2 | last post by:
I am not able to create following store procedure. CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT ) RESULT SETS 1 LANGUAGE SQL BEGIN part1 DECLARE TOTAL_LEFT INT DEFAULT 0; ...
9
by: erictheone | last post by:
Ok so what I'm trying to do is create a trans location cipher. For those among us that don't know alot about cryptography it is a method for jumbling up letters to disguise linguistic...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.