I am trying to understand this program from my class I under
I am trying to understand this program from my class. I understnad the basic form of the throw catch excption, but I don\'t understand what the cerr function does. It looks like it\'s for an output error msg of sorts? Anyways, when I run this program, it doesn\'t output the error msg even though p.fly is called. can someone explain this? Thanks in advance. // #include<iostream> #include<string> using namespace std; class BirdException { public: BirdException(const string s) : msg(s) {} // Does this imply that it is inhearting the msg function for this class? string msg; }; class Bird { public: virtual void fly(void) = 0; }; class Penguin : public Bird { public: virtual void fly(void) { throw BirdException(\"oops, penguins can\'t fly\"); } }; int main() { Penguin p; try { p.fly(); } catch ( BirdException& be ) { cerr << \"Exception caught: \" << be.msg << endl; } } Solution
It displays the error message. I got output as below
Exception caught: oops, penguins can\'t fly
I am using vc++ 2013 .I checked on Unix environment, got same output
