jeudi 14 janvier 2021

Why does string doesn't work here while char const* does?

Why does string doesn't work here when I catch an error and char cont* does? What is the difference between the two?

try {
    throw "connection fail";

} catch( string e ) {
    if(e == "connection fail") {
        std::cout << "caught: " << e << std::endl;
    }
}

Aucun commentaire:

Enregistrer un commentaire