「🔨」 fix(ex02): added a const operator[] overload (readonly ofc)
This commit is contained in:
@@ -33,6 +33,15 @@ public:
|
||||
return _arr[pos];
|
||||
}
|
||||
|
||||
T &operator[](const size_t &pos) const
|
||||
{
|
||||
if (pos < 0 || pos >= _size)
|
||||
{
|
||||
throw outOfBoundException();
|
||||
}
|
||||
return _arr[pos];
|
||||
}
|
||||
|
||||
class outOfBoundException : public std::exception {
|
||||
virtual const char *what() const throw()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user