Please explain a statement

I need to understand how a statement works. You can find it at this website:

http://www.librow.com/articles/article-10

It is Librow FFT. Here is this code:

1
2
3
4
void CFFT::Perform(complex *const Data, const unsigned int N,
                                  const bool Inverse /* = false */)
{
   const double pi = Inverse ? 3.14159265358979323846 : -3.14159265358979323846;


I highlighter the statement that puzzles me. Please explain. Thanks.

That statement is similar to:
1
2
3
4
if (Inverse)
    const double pi = 3.14159265358979323846;
else
    const double pi = -3.14159265358979323846;


This is called the ternary operator.

In this case, it's very useful since const must be initialized and getting it the correct scope can prove sloppy. The ternary operator returns the result where as my if/else statement would not.
Thank you, but I don't understand why Inverse must be a const.
It doesn't have to be a const.
Topic archived. No new replies allowed.