blob: dd5fb6bda36d62b5bd5f0f852e878376806440c5 (
plain) (
blame)
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
|
#pragma once
#include "Container.hpp"
template <class T>
class Indexable : virtual public Container<T> {
public:
T& operator[](unsigned index);
const T& operator[](unsigned index) const;
};
template <class T>
T& Indexable<T>::operator[](unsigned index) {
if (index > this->size) {
throw "Index out of range!";
}
return this->arr[index];
}
template <class T>
const T& Indexable<T>::operator[](unsigned index) const {
if (index > this->size) {
throw "Index out of range!";
}
return this->arr[index];
}
|