Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Full version:
- // (Note that generally speaking utility functions go at the top,
- // with main functions calling the functions above.
- // Therefore start from main() and follow the program execution.)
- #include <iostream>
- #include <exception>
- struct mongolian_vd : std::exception
- {
- const char *what() const throw()
- {
- return "Mongolian VD!";
- }
- };
- namespace sti
- {
- void fun();
- }
- void catch_mongolian_vd()
- {
- std::cout << "\tUnmentionable acts have been commited!\n\n";
- // throw to catch? huh?
- throw mongolian_vd();
- }
- void sti::fun()
- {
- std::cout << "Executing sti::fun() ...\n";
- catch_mongolian_vd();
- }
- void chinese_herbalism()
- {
- std::cout << "Trying chinese_herbalism()\n\n";
- std::cout << "\tThe Chinese herbalist says:\n";
- std::cout << "\t\tWhat? Western doctor tell you need to amputate?!\n";
- std::cout << "\t\tHa ha ha ha ha!\n\n";
- std::cout << "\t\tNo! Operation is very expensive!\n";
- std::cout << "\t\tWestern doctor just want money!\n\n";
- std::cout << "\t\tNo, no, no, no, we do not need amputate. You just relax.\n\n";
- std::cout << "\t\t... just wait two week, penis fall off on its own!\n\n";
- }
- void aromatherapy()
- {
- enum class scent_t
- {
- yes = 0,
- no = 1,
- maybe = 2,
- verytrue = 3,
- untrue = 4,
- undefined = 5,
- patchouli = 9001,
- };
- std::cout << "Trying aromatherapy()\n\n";
- scent_t olfactory_receptor = scent_t::patchouli;
- std::cout << "\tMmmh, patchouli.\n\n";
- }
- void poke(int &address, int value)
- {
- address = value;
- }
- void accupuncture()
- {
- std::cout << "Trying accupuncture()\n\n";
- // this integer represents the number of needles in your back
- int back = 0;
- poke(back, 15);
- std::cout << "\tOuch!\n\n";
- }
- void seek_cure_from_alternative_medicine()
- {
- accupuncture();
- aromatherapy();
- chinese_herbalism();
- }
- bool western_medicine()
- {
- std::cout << "Seeking cure from western_medicine():\n\n";
- std::cout << "\tThe Doctor says:\n";
- std::cout << "\t\tI'm very sorry to have to tell you this ...\n";
- std::cout << "\t\tWe have no choice ...\n";
- std::cout << "\t\t... but to fully amputate your penis, immediately.\n\n";
- const bool accept_prognosis = false;
- return accept_prognosis;
- }
- int main(int argc, char **argv)
- {
- try {
- sti::fun();
- } catch (mongolian_vd &exception) {
- std::cout << "Caught: " << exception.what() << "\n\n";
- if (!western_medicine()) {
- std::cout << "\twestern_medicine() returned false and was unable to provide a cure!\n\n";
- seek_cure_from_alternative_medicine();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement