🔨」 fix(ex02): added a const operator[] overload (readonly ofc)

This commit is contained in:
2025-08-18 20:01:42 +02:00
parent e0535f2b4a
commit cbd45d0f14
2 changed files with 11 additions and 1 deletions

View File

@@ -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()
{