我有一個字符串指針string* ifxPtr;
,我想要做的就是將此指針設置爲指向用戶輸入,然後遍歷每個字符。將先前分配的指針值傳遞給循環
string* ifxPtr;
void Expression::GetInfix(string data) // This method runs first and it's setting the pointer to point to previously passed user input
{
ifxPtr = &data;
ConvertToPostfix();
}
void Expression::ConvertToPostfix()
{
for (int i = 0; i < *ifxPtr->length; i++) // Here's the struggle, compiler is complaining about *ifxPtr with message Cannot apply binary '<' to 'int' and 'unassigned() const'
{
//Do something here
}
}
我甚至沒有發現'1',好的一個。 –
這樣一個愚蠢的錯誤,但那是問題。 –