Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85750588
ch-08-ex-04-solution.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Oct 1, 21:10
Size
785 B
Mime Type
text/x-c
Expires
Thu, Oct 3, 21:10 (2 d)
Engine
blob
Format
Raw Data
Handle
21261512
Attached To
R9360 PCSC_git
ch-08-ex-04-solution.cpp
View Options
/*
* chapter-08-exercise-04.cpp
*
* STL and 2D Point class
*
* Created on: Nov 1, 2012
* Author: Radu Popescu <radu.popescu@epfl.ch>
*/
#include <iostream>
#include <set>
#include "Point2d.hpp"
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
set
<
Point2d
>
points
;
// Set the tolerance for the comparison operator of Point2d
Point2d
::
sTolerance
=
1e-6
;
Point2d
origin
(
0.0
,
0.0
);
points
.
insert
(
origin
);
points
.
insert
(
Point2d
(
-
2.0
,
1.0
));
points
.
insert
(
Point2d
(
-
2.0
,
-
5.0
));
points
.
insert
(
Point2d
(
0.0
,
0.0
));
std
::
cout
<<
"Number of points in set = "
<<
points
.
size
()
<<
"
\n
"
;
std
::
set
<
Point2d
>::
const_iterator
c
;
std
::
cout
.
precision
(
3
);
for
(
c
=
points
.
begin
();
c
!=
points
.
end
();
c
++
)
{
std
::
cout
<<
c
->
x
<<
" "
<<
c
->
y
<<
"
\n
"
;
}
return
0
;
}
Event Timeline
Log In to Comment