expected primary-expression before "void"

S

sandy

I cannot figure this out.

I have the following code:

<code>
Private:


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

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

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

</code>

which is in the header of my file. I get the error:
\JobCollection.h expected primary-expression before "void"

What is causing the error?
What is a 'Primary' expression?


I have tried removing the void, still have an error. I put the void in
the function in the .cpp, I get the error, I take it out of the .cpp I
get the error.

I cannot figure this out...
 
L

Larry Smith

I cannot figure this out.

I have the following code:

<code>
Private:


What is 'Private:' ?

Has 'ListType' already been defined?

Is this code snip INSIDE a 'class' or 'struct'
definition (I hope so...)? For example:

struct myStruct
{
private:

void CreateList(ListType *list);

/* other stuff for struct myStruct here */
};
 
S

sandy

Larry said:
Is this code snip INSIDE a 'class' or 'struct'
definition (I hope so...)? For example:

struct myStruct
{
private:

void CreateList(ListType *list);

/* other stuff for struct myStruct here */
};

Thanks for replying. I managed to fix that problem. Now I am posting a
new one.

I am a student and I think my brain is on overflow from syntax errors.
 
E

Earl Purple

out of interest why did you use struct rather than class. While it's
true that they are exactly the same apart from default access and
inheritance, it seems more natural to use class.
I am a student and I think my brain is on overflow from syntax errors.

Don't worry, I am a seasoned programmer and it's extremely rare that I
right a bunch of code and not have any syntax errors when you get to
compile it.

Sometimes the compilers don't always tell you what your actual error
is. For example, looking at the declaration it is obvious to me that
CreateList is a function name and ListType is a type. If ListType has
not been declared I would like compilers to give:

ListType: undefined type.

rather than some other message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top