#include using namespace std; class Document { public: Document ( void ) : docid ( 0 ) { } int get_docid ( void ); private: int docid; }; int Document::get_docid ( void ) { return docid; } class Book : public Document { public: Book ( void ) : Document ( ), bookid ( 0 ) { } int get_bookid ( void ); private: int bookid; }; int Book::get_bookid ( void ) { return bookid; } int main ( void ) { Book mybook; try { throw mybook; } catch ( Document &d ) //违背1 { cout << d.get_docid ( ) << endl; } catch ( Book &b ) //违背2 { cout << b.get_bookid ( ) << endl; } return ( 0 ); }