Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
examples
manual
max.cpp
Go to the documentation of this file.
1
29
#include <algorithm>
// for max, min
30
#include <functional>
// for greater
31
#include <iostream>
// for cout
32
33
#include <
examples.h
>
34
35
36
int
main
()
37
{
38
double
d1
= 10.0,
d2
= 20.0;
39
40
// Find minimum.
41
double
val1 = std::min (
d1
,
d2
);
42
43
// The greater comparator returns the greater of the two values.
44
double
val2 = std::min (
d1
,
d2
, std::greater<double>());
45
46
// Find minimum.
47
double
val3 = std::max (
d1
,
d2
);
48
49
// The less comparator returns the smaller of the two values.
50
51
// Note that, like every comparison in the library, max is
52
// defined in terms of the < operator, so using less here
53
// is the same as using the max algorithm with a default
54
// comparator.
55
double
val4 = std::max(
d1
,
d2
, std::less<double>());
56
57
std::cout << val1 <<
" "
<< val2 <<
" "
58
<< val3 <<
" "
<< val4 << std::endl;
59
60
return
0;
61
}
d1
#define d1
Definition
17.names.cpp:228
d2
#define d2
Definition
17.names.cpp:254
examples.h
main
int main()
Definition
max.cpp:36
Generated by
1.9.8