2009-12-20 92 views
0
#include <stdexcept> 
#include <string> 

using namespace std; 

class ListIndexOutOfRangeException : public out_of_range 
{ 
public: 
    ListIndexOutOfRangeException(const string & message = "") : out_of_range(message.c_str()) 
    { 
    } 
}; // end ListIndexOutOfRangeException 

回答

1

out_of_range接受一個字符串引用,所以只需使用

: out_of_range(message) 

代替。

編輯:

正如其他人所說,編譯器是告訴你,你已經使用message.cstr()代替message.c_str()。但方法調用是不必要的,只是傳遞字符串。

+0

尼斯之一!謝謝。 – Brandon 2009-12-20 11:45:38

相關問題