开发者

How do I resolve: "error C2039: 'cstr' : is not a member of 'std::basic_string"?

#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


out_of_range accepts a string reference, so just use

: out_of_range(message)

instead.

edit:

And as others have said, the compiler is telling you you have used message.cstr() instead of message.c_str(). But the method call is unnecessary anyway, just pass the string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜