Changed int to size_t when needed for compilation and added stdexcept for std::out_of_range