Given the following two constructor signatures, is it possible to build a Couplec Couple("George", "Nora")? My compiler complains about the error shown below. If I call him Couple(std::string("George"), std::string("Nora")), he will compile OK. I assume that the problem with implicit casting is surprising to me, because despite the fact that char * for the string will be fine.
class Person
{
public:
Person(const std::string& name);
};
class Couple
{
public:
Coordinate(const Person& p1, const Person& p2, const Optional<Person>& = Optional<Person>());
};
TestCouple.cpp:69: error: no matching function for call to `Couple::Couple(const char[7], const char[5])'
TestCouple.h:24: note: candidates are: Couple::Couple(const Person&, const Person&, const Optional<fox::Person>&)
source
share