C Program Exception Handling TrashCan which has been diagra
C++ Program - Exception Handling
TrashCan which has been diagrammed below. I\'d like you to enhance this class so that invoking its methods or operators potentially throw exceptions, rather than just printing error messages to cout. Currently, our favorite exception class is std:logic error. You can create a logic error by passing a string value to its constructor Officially, you should also say #includeSolution
For having content value that exceeds the size value: -
in std::out_of_range can be used
class out_of_range : public_logic_error {
public:
explicit out_of_range(const &strings what_arg);
}
#include<iostream>
#include<stdexcept>
#include<vector>
int main(void)
{
std::vector<int>mytestvector(size);
try{
mytestvector.at(size++)=5000;
}
return 0;
}
A negative number that is stored as contents value :-
class underflow_error : public exception {
public:
explicit underflow_error( const string& what_arg);
explicit logic_error(const char* what_arg);
}
#include<iostream>
#include<stdexcept>
#include<vector>
int main(void)
{
std::vector<int>mytestvector(1000);
try{
if
if(mytestvector.at(content)<0)
cout<<\"error\";
}
return 0;
}
A negative number stored as size value:-
class underflow_error : public exception {
public:
explicit underflow_error( const string& what_arg);
explicit logic_error(const char* what_arg);
}
#include<iostream>
#include<stdexcept>
#include<vector>
int main(void)
{
std::vector<int>mytestvector(1000);
try{
if
if(mytestvector.at(size)<0)
cout<<\"error\";
}
return 0;
}

