blob: e26dc47bdedc736dff7b196d3b8bfdc137b9b6e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Triplet.h
// A sample user-defined data type for illustrating ConfigFile
// Operators << and >> are defined to allow writing to and reading from files
// Richard J. Wagner 24 May 2004
#include <iostream>
struct Triplet
{
int a, b, c;
Triplet() {}
Triplet( int u, int v, int w ) : a(u), b(v), c(w) {}
Triplet( const Triplet& orig ) : a(orig.a), b(orig.b), c(orig.c) {}
Triplet& operator=( const Triplet& orig )
{ a = orig.a; b = orig.b; c = orig.c; return *this; }
};
std::ostream& operator<<( std::ostream& os, const Triplet& t )
{
// Save a triplet to os
os << t.a << " " << t.b << " " << t.c;
return os;
}
std::istream& operator>>( std::istream& is, Triplet& t )
{
// Load a triplet from is
is >> t.a >> t.b >> t.c;
return is;
}
|