It seems that you did not include header <stdexcept>
Throwing a std::out_of_range exception. "expected type-specifier"
سؤال
I am making a class that should be a very poor string
, but I have this issue with the at
methods.
MyString.h
char at(unsigned int i) const throw(std::out_of_range);
char& at(unsigned int i) throw(std::out_of_range);
MyString.cpp
char MyString::at(unsigned int i) const throw(std::out_of_range) {
if (mylength_ == 0 || i < 0 || i > mylength_ - 1)
throw std::out_of_range("nopenope");
return string_[i];
}
char& MyString::at(unsigned int i) throw(std::out_of_range) {
if (mylength_ == 0 || i < 0 || i > mylength_ - 1)
throw std::out_of_range("nopenope");
return string_[i];
}
المحلول
لا تنتمي إلى StackOverflow