. Advertisement .
..3..
. Advertisement .
..4..
I am working with cpp and getting the error message:
error: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid
Here is the detail of the code that I ran:
if(player!=NULL)
player->shuffled();
I need an explanation for the problems I’ve encountered. How to fix terminate called after throwing an instance of ‘std::logic_error’?
The cause:
You get the ”terminate called after throwing an instance of ‘std::logic_error’” issue because the
std::string
constructor is being called with theconst char*
value NULL somewhere.Solution:
To solve this error, you mustn’t call the std::string constructor with the const char* value NULL.
You’re calling the
std::string
constructor somewhere with theconst char*
null value.To avoid the problem. Do not do this.