Throwing an error when initializing an object in c++
Pet(const string &amp; the_name, const string &amp; the_species): name(the_name), species(the_species), age(0)
  {

     if (species == "cats" || species == "dogs")
        throw std::invalid_argument( "received negative value" );
  }