PDA

View Full Version : error: expected primary-expression before '=' token



Ketan Shah
20th May 2011, 14:56
(void)new Q3CheckListItem (ui->view,*it, Q3CheckListItem::Type = Q3CheckListItem::CheckBox );

got this error,
error: expected primary-expression before '=' token

plz help...

SixDegrees
20th May 2011, 15:12
You need to assign the result of the code shown to something.

FelixB
20th May 2011, 15:23
you can't assign something to an enum...


Q3CheckListItem::Type = Q3CheckListItem::CheckBox

Santosh Reddy
20th May 2011, 17:41
Do you mean


(void)new Q3CheckListItem (ui->view,*it, Q3CheckListItem::CheckBox );

DanH
20th May 2011, 23:18
You're confusing how you prototype a method with how you actually code it for a call. In the prototype description something like "Q3CheckListItem::Type = Q3CheckListItem::CheckBox" means that that parameter is optional and will take the value "Q3CheckListItem::CheckBox" if you omit it in the call. If you want a different value you'd simply code the value. Eg:

"... someParm, Q3CheckListItem::ShoeBox)"

for the case where one of the enum values from Q3CheckListItem is expected.

And I'm not sure where you got the "(void)".

(And, of course, you shouldn't be using the Q3 stuff.)

ChrisW67
21st May 2011, 01:06
The (void) explicitly discards the returned pointer from the call to new, makes it obvious you intended to discard the return value, and avoids a warning from compilers that issue one when you ignore a return. OTOH, if it weren't for QObject's memory management this construct would create a memory leak.