Fixes
This commit is contained in:
@@ -19,9 +19,8 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void swap(T &a, T &b)
|
void swap(T &a, T &b)
|
||||||
{
|
{
|
||||||
T tmp;
|
T tmp = a;
|
||||||
|
|
||||||
tmp = a;
|
|
||||||
a = b;
|
a = b;
|
||||||
b = tmp;
|
b = tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class Array
|
|||||||
~Array();
|
~Array();
|
||||||
|
|
||||||
T &operator[](unsigned int i);
|
T &operator[](unsigned int i);
|
||||||
|
T const &operator[](unsigned int i) const;
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ T &Array<T>::operator[](unsigned int i)
|
|||||||
return (data[i]);
|
return (data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T const &Array<T>::operator[](unsigned int i) const
|
||||||
|
{
|
||||||
|
if (i >= _size)
|
||||||
|
throw std::exception();
|
||||||
|
return (data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned int Array<T>::size() const
|
unsigned int Array<T>::size() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user