Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
w1
Using C's sprinf() Function to Format Output String
generate BinTree from sorted list
Tower of hanoi
runtime template mode processor
CountingSort
Dictionary
VecCrossProd
Rev Fact WIP
Abejas beta
Please log in to post a comment.