Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
InviteList
//g++ 7.4.0 //InviteList: demonstration of exception (try,catch,throw) //this code is created by Rezaul Hoque on November 12,2021;contact: jewelmrh@yahoo.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> using namespace std; string inviteList(string s) { cout<<"Please identify yourself:\n"; cin>>s; if (s =="Martian"||s==" martian"||s=="Mermaid"||s=="mermaid") { throw "Sorry, you are not invited!"; } return s; } int main() { string k; try { string st; st = inviteList(k); cout <<st; cout<<",you're invited!"; } catch (const char* display) { cerr <<display << endl; } return 0; }
run
|
edit
|
history
|
help
0
GoF interpreter
2222aaaa
My calculator
Dijkastra
ONP
EqualIdentical
Zahra_matrix
project euler problem - 3
PATRA_Class_test
XD