-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.h
59 lines (50 loc) · 997 Bytes
/
template.h
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Typedefs for the application
/*!
* @author diehlpk
* @date 2012
*/
#ifndef TEMPLATE
#define TEMPLATE
#include <cstdlib>
#include <cassert>
//! Template for a basic array data type.
/*!
* \param T The datatype or class of the elemtens in the array.
* \param size The size of the array.
*/
template < class T, size_t size > class Array
{
private:
//! The elements of the array.
T coord[size];
public:
//! Constructor.
Array (void)
{
for (size_t d = 0; d < size; ++d)
coord[d] = 0;
}
//! Destructor.
~Array (void)
{
}
//! Operator returns the element with the index index.
/*!
* \param index The index of the element.
*/
T & operator[](size_t index)
{
assert (size > index);
return coord[index];
}
//! Operator returns the element with the index index.
/*!
* \param index The index of the element.
*/
const T & operator[] (size_t index) const
{
assert (size > index);
return coord[index];
}
};
#endif