I don't know what i'm missing, but I keep getting the error in the poly_tst file when trying to compile that says 'expected primary-expression before ']' token. According to my book I'm writing everything correctly.

Here is my class file function (poly.h)

void setcoeff(Term);

Here is my implementation file definition (poly.cpp)

void poly::setcoeff(Term Termholder[])

Here is my driver file function call (poly_tst.cpp)


Other notes is that I have a structure called Term that I created in the class that I made an array of 10 elements of called Termholder, and that my declared instance of a poly is called polyinstance

7 Years
Discussion Span
Last Post by mike_2000_17

polyinstance.setcoeff(Termholder[]); -- you don't need []. Also void setcoeff(Term)!=void poly::setcoeff(Term Termholder[]), first declares function taking one Term argument, and the second defines function taking array of Term argument.

Edited by Zjarek: n/a


Zjarek is correct.
And the error message is related to the fact that the use of [] without anything inside of it is only permitted in a few cases (when declaring a parameter to a function or when declaring a static array whose size is determined by its initializer), in all other cases, the compiler expects you to put something in-between (i.e. an index) and when it does not find it, it throws an error "expected primary-expression".

Edited by mike_2000_17: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.