'-'
符号を調べ、その前に' '
(スペース)がある場合は、マイナス符号かマイナス符号かを確認する関数を作成しようとしています。私は現在のチャー(infix[x]
)と比較して、infix[x+1]
と比較することでそうしています。私は間違いを続けているが、私は正確に何か他のものを渡していないので、私は確信していない?文字列とcharをブール関数に渡す際のエラー
for(unsigned x = 0; x < infix.length(); ++x)
{
// place numbers (standard, decimal, & negative)
// numbers onto the 'postfix' string
if((isdigit(infix[x])) || (infix[x] == '.'))
{
postfix += infix[x];
}
else if ((infix[x] == '-'))
{
if(checkfornegative(infix[x], infix)== 1)) // error: expected primary-expression before ‘)’ token
if(checkfornegative(infix[x], infix)== 1))
{
postfix+= " ";
}
else if(checkfornegative(infix[x], infix)== 0)) //error: expected primary-expression before ‘)’ token
if(checkfornegative(infix[x], infix)== 1))
{
postfix += infix[x];
}
}
// This is the function in using
bool checkfornegative(char C, string& QQ)
{
bool status;
if((C == '-') && (QQ[C+1] == ' '))
{
status = true;
}
else if((C == '-') && (QQ[C+1] != ' '))
{
status = false;
}
return status;
}
最小限の完全な例の点でここでいくつかのコンテキストを持つことは、かなり助けになります。これらの関数はどのように呼び出されますか?あなたはどのようなデータを提供していますか? – tadman
あなたのかっこはバランスが取れていません。これは実行しているコードにすることはできません。 – Barmar
QQ [C + 1]は意味をなさない。 'C'は文字であり、文字列のインデックスではありません。 – Barmar