所以这是我的标题:
//warehouse.h
#ifndef WAREHOUSE_H
#define WAREHOUSE_H
#include<string>
#include<map>
#include "dates.h"
namespace a4
{
class warehouse
{
public:
warehouse(std::string name, std::string start_date);
private:
std::string name;
std::string busiest_day;
int most_transactions;
dates current_date;
std::map<std::string, a4::food> items;
void next_day();
};
}
#endif
我的.cc:
//warehouse.cc
#include "warehouse.h"
#include "dates.h"
namespace a4
{
//constructor
warehouse::warehouse(std::string wname, std::string start_date)
{
wname = name;
current_date = dates(start_date);
}
void warehouse::next_day()
{
current_date.next_day();
}
}
和编译器错误:
warehouse.cc: In constructor ‘a4::warehouse::warehouse(std::string, std::string)’:
warehouse.cc:6: error: no matching function for call to ‘a4::dates::dates()’
dates.h:10: note: candidates are: a4::dates::dates(std::string)
dates.h:8: note: a4::dates::dates(const a4::dates&)
从错误来看,它看起来像是在调用零参数构造函数,而不是采用字符串的构造函数。我构建的日期类显然没有零参数构造函数。
几个小时以来,我一直试图解决这个问题,任何帮助将不胜感激。在一个类似的问题中,我被告知要查找成员初始值设定项列表。我猜我已经并且不太了解如何正确实施它,因为它似乎无法解决问题。
刚开学几周,这是我的第一堂 C++ 课,放轻松 :)