문제

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];
}
도움이 되었습니까?

해결책

It seems that you did not include header <stdexcept>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top