well you could do like an array/list/vector/stack that stores every digit. so when you input "523" as a string you can cut it up to "5", "2" and "3".
something like
stack<int> intStack;
then u pass into a function by refernce
1 2 3 4 5 6 7 8 9
void tokenise (string str, stack<int> &intStack) {
stringstream token(str); //a standard stringstream which parses 'str'
string temp; //a temporary string
while (token >> temp){ // while the string has not been completely copied
int number = convertToInt(checking); // assign "number" a value by converting "checking" into an int
intStack.push(number); // store "number" into the stack
}
};
void tokenise (string str, stack<int> &intStack) {
stringstream token(str); //a standard stringstream which parses 'str'
string temp; //a temporary string
int number
while (token >> temp){ // while the string has not been completely copied
number = convertToInt(temp); // assign "number" a value by converting "checking" into an int
intStack.push(number); // store "number" into the stack
}
};
"checking" in int number = convertToInt(checking); refers to the string in which user has typed
It seems that you are right. The third operand shall be casted to void. According to the C++ Standard
2 If either the second or the third operand has type void, then the lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on the second and third operands, and one of the following shall hold:
— The second or the third operand (but not both) is a throw-expression (15.1); the result is of the type of the other and is a prvalue.
— Both the second and the third operands have type void; the result is of type void and is a prvalue.
[ Note: This includes the case where both operands are throw-expressions. —end note ]
So the expression shall be written as
( x /= 10 ) ? reverse( x ) : void( std::cout << std::endl ) ;