//g++ 7.4.0
///////////////////////////////////////////////////////////////////////////////ExceptionHandling3: C++ exception handling
//this code is created by Rezaul Hoque on June 10,2022;
//contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com
//note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning;
/////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
class Name{
std::string nam;
public:
Name(std::string n){if(n==" ")
throw " Name field can't be empty!";
else
nam=n;
}
~Name(){}
std::string getNam(){return nam;}
void disp(){std::cout<<getNam();}
};
int main()
{
try{
Name a(" ");
a.disp();
catch(const char* text){
std::cerr<<text;
return 0;
g++
Error(s):
Name field can't be empty!