Stop C++ Class Instantiation
问题 Is there a way to stop a C++ class if there is an error in the instantiation? Like, return NULL maybe? Basically I have a wrapper class for MySQL, and the constructor does the connecting, but if the connection fails, I want the object to be, um, useless? PDB::PDB(string _DB_IP, string _DB_USER, string _DB_PASS, string _DB_DB) : _DB_IP( _DB_IP ), _DB_USER( _DB_USER ), _DB_PASS( _DB_PASS ), _DB_DB( _DB_DB ) { mysql_init(&this->mysql); this->connection = mysql_real_connect(&this->mysql, this->