what is this codes mean ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// function template
#include <iostream>
using namespace std;

template <class T>
T GetMax (T a, T b) {
  T result;
  result = (a>b)? a : b; //what is this mean ?
  return (result);
}

int main(int argc, char *argv[])
{
  int i=5, j=6, k;
  long l=10, m=5, n;
  k=GetMax<int>(i,j);
  n=GetMax<long>(l,m);
  cout << k << endl;
  cout << n << endl;
  system("PAUSE");
  return EXIT_SUCCESS;
}

my froblem is i dont understand the mean of this code "(a>b)? a : b;"
result = (a>b)? a : b; means:
1
2
3
4
if ( a>b )
    result = a;
else
    result = b;
http://www.cplusplus.com/doc/tutorial/operators/ (see Conditional Operator )
thanks , its verry usefull
Topic archived. No new replies allowed.