내 연결된 목록이 비어 있지만 EmptyListException()을 주석 처리하지 않으면 프로그램이 종료를 계속할 때 EmptyListException을 발생 시키려고합니다. 이 내 EmptyListException 헤더C++ 예외 잡히지 않았습니다
#ifndef EMPTYLISTEXCEPTION_H
#define EMPTYLISTEXCEPTION_H
#include <stdexcept>
using std::out_of_range;
class EmptyListException : public out_of_range
{
public:
EmptyListException(): out_of_range("Empty List!\n") {}
};
#endif // EMPTYLISTEXCEPTION_H
입니다 - Clist.h에
template <typename E>
E Clist<E>::Remove() throw()
{
if(isEmpty())
{
cout << "Empty List, no removal";
//throw EmptyListException();
return '.';
}
... code
}
명령을 던져 -이 응용 프로그램 '홈페이지
try{
cout << list->Remove() << endl;
} catch(EmptyListException &emptyList)
{
cout << "Caught :";
cout << emptyList.what() << endl;
}
오류에서 캐치를 런타임에 요청했다 비정상적인 방법으로 종료하십시오. 자세한 내용은 응용 프로그램 지원 팀에 문의하십시오.
왜'복귀, ''. '? E는 챠일 일 필요가 없다. – LeeNeverGup
'Remove()'의 정의에서'throw()'를 제거해보십시오. – xaizek
돌아 가기 '.'; 난 그냥 함수를 끝내고 싶어요, 다시 빈 데이터 형식을 보내고 싶었어요. 보통이 함수는 제거 된 노드 데이터를 반환합니다. – George