What are the commas for?

This is a really silly question but it's something I'm not sure how to look up.

1
2
3
4
5
template <class T>
void Stack<T>::resize() throw (const char *)
{
  resize(capacity == 0 ? 1 : capacity * 2, tosIndex, pStackData);
}


What are the commas for? Is he assigning a value to "tosIndex" or "pStackData". All of these are variables, not functions.
It looks like a function called resize is being called, and it takes 3 argumenst as parameter.

capacity == 0 ? 1 : capacity * 2


Is another way of writing if statement, forgot what it's called. And as second and third parameter you are passing tosIndex and pStackData.
Yeah, that's right. I thought it was some crazy syntax for a second but it really is just a call to the overloaded function resize.
closed account (E0p9LyTq)
capacity == 0 ? 1 : capacity * 2 is an example of the conditional ternary operator ( ? ).
http://www.cplusplus.com/doc/tutorial/operators/
Topic archived. No new replies allowed.