Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ExceptionHandling3
//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; }
run
|
edit
|
history
|
help
0
Palindrome
CPP - Arrays - Ex.3
OperatorOverload
Expected GCD
PriorQ
Suma
binder
ApelRefVal
Изволов#2
Two-phase sample with GCC