Error: Expected Primary Expression Before [ Token

Thanks for everything
Last edited on
Try replacing MiniStack with stackPtr. You don't want to index the class (that is meaningless in this situation), you want to index the array pointed to by stackPtr.

Also, line 9 should be stackPtr = new char[MINI_STACK_SIZE];. You are currently allocating an array of ints that is never being used.
Last edited on
That worked, thanks! May I ask why it's meaningless to index the class though? Why can't I access a point in the stack array like I would a regular array?
May I ask why it's meaningless to index the class though

Because a class is a type. It's no more meaningful to try and access the value of "MiniStack" than it is to access the value of "int" or of "char".

It's the object that has data, not the type.
Topic archived. No new replies allowed.