By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 827 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

expected primary-expression before "void"

P: n/a
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...

Oct 5 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
sa***@murdocks.on.ca wrote:
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 */
};
>

/************************************************** ****************************
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...
Oct 5 '06 #2

P: n/a

Larry Smith wrote:
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.

Oct 5 '06 #3

P: n/a

sa***@murdocks.on.ca wrote:
struct myStruct
{
private:

void CreateList(ListType *list);

/* other stuff for struct myStruct here */
};
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.

Oct 5 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.