Hi everyone,
I want to derive some exception classes from std::exception, which serve as bug-hunting devices with specific messages. But the screen output seems really awkward to me. An example:
This result in the following screen output:Code:class VectorException: public exception { public: VectorException() : message( (string)"Vector: ") {}; VectorException( string const& mess) : message( (string)"Vector: " + mess) {}; virtual const char* what() const throw() { return message.c_str(); } private: string const& message; }; int main() { try { v[ 3]; //throws the exception catch( exception& e) { cout<< "Exception running testVector: "<< e.what()<< endl; } return 0; }
Might it be the string-member function 'c_str()' which causes the problem?Code:Exception running testVector: �d��P�ͷ�l�����d��P�ͷ



LinkBack URL
About LinkBacks


