I have a stack of UTF8 characters:
stack<wchar_t> tokenStack;
i try to add to it like this:
void doLeftParen() { tokenStack.push( L"(" ) }
but the compiler doesn't like it:
$ g++ PropositionalLogic.cpp -o PropositionalLogic
PropositionalLogic.cpp:27:39: error: reference to type 'const value_type' (aka 'const wchar_t') could not bind to an lvalue of type 'const wchar_t [2]' void doLeftParen() { tokenStack.push( L"(" ) }
I tried searching for the error, but came up empty. I'm not really sure what else i should be searching for. I've also tried just adding a regular ASCII character, but same error. How can i add characters to this stack?
You're trying to push a string not a char, changing the double quotes to single quotes will make it work, also you're missing a semi-colon at the end of the push function
void doLeftParen() { tokenStack.push( L'(' ); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With