بله چرا که نه
شما داخل تابع throw رو مینویسی بعد داخل main از try catch استفاده می کنی
می تونی برای Exception از کلاس exception خود c++ یا QException کیوت هم ارث ببری ویک شی از اون رو برگردونی .
مثال :
#include <iostream>
#include <exception>
using namespace std;
class NameException
{
public:
virtual const char* what() const throw()
{
return "Name is too small !\n";
}
} nameException;
string getName()
{
std::string name;
cin>>name;
if(name.size()<5)
throw nameException;
return name;
}
int main()
{
string name;
try{
name=getName();
}
catch(const NameException& e){
cout<<e.what();
}
}