Czon
Czon

Reputation: 299

How to avoid the error: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid

if(player!=NULL)
    player->shuffled();

I do such things to avoid passing a null reference to a string constructor, but when compiling it still comes to error.

Upvotes: 26

Views: 110740

Answers (1)

Dave S
Dave S

Reputation: 21113

Somewhere, somehow, you're calling the std::string constructor with the const char* value NULL.

To avoid the problem. Don't do that.

Upvotes: 90

Related Questions