私の main() を呼び出したい
program p;
p.isPath("c9", "c5")
program.h は
stack<City> isPath(City, City);
program.cpp は
stack<City> Program::isPath(City originCity, City destCity)
{
stack<City> flight; // = new Stack<City>();
originCity.setVisited(true);
flight.push(originCity);
checkPath(&originCity, &destCity, &flight);
return flight;
}
都市のスタックが作成され、都市が次のようにスタックに追加されます。
Program::Program()
{
City* c1 = new City("C1");
City* c2 = new City("C2");
City* c3 = new City("C3");
City* c4 = new City("C4");
City* c5 = new City("C5");
City* c6 = new City("C6");
City* c7 = new City("C7");
City* c8 = new City("C8");
City* c9 = new City("C9");
Program::found = true;
list<City>* allCities = new list<City>();
this->allCities->push_back(*c1);this->allCities->push_back(*c2); this->allCities->push_back(*c3);allCities->push_back(*c4); this->allCities->push_back(*c5);
this->allCities->push_back(*c6); this->City destCityallCities->push_back(*c7); this->allCities->push_back(*c8); this->allCities->push_back(*c9);
c1->addCityToCities(c7);
c1->addCityToCities(c2);
c2->addCityToCities(c3);
c3->addCityToCities(c4);
c4->addCityToCities(NULL);
c5->addCityToCities(c7);
c6->addCityToCities(c5);c7->addCityToCities(c6); c7->addCityToCities(c8);c8->addCityToCities(c2); c8->addCityToCities(c9);c9->addCityToCities(c6);
City クラスには次のコードがあります。
City::City()
{
list<City>* cities = new list<City>();
}
City::City(string _name){
this->name = _name;
list<City>* cities = new list<City>();
visited = false;
このエラーメッセージが表示されます
main.cpp: error: no matching function for call to 'Program::isPath(const char [3], const char [3])'
main.cpp: note: candidate is:
\include\Program.h: note: std::stack<City> Program::isPath(City, City)
\include\Program.h: note: no known conversion for argument 1 from 'const char [3]' to 'City'
巡回セールスマンアプリです。誰でもこのエラーを解決するのを手伝ってくれませんか。