所以我有这个仓库类:
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;
std::map<std::string, a4::food> items;
dates current_date;
void next_day();
};
}
#endif
warehouse.cc:
#include "warehouse.h"
#include "dates.h"
namespace a4
{
//constructor
warehouse::warehouse(std::string name, std::string start_date)
{
this->current_date = new dates(start_date);
}
void warehouse::next_day()
{
this->current_date.next_day();
}
}
我得到的编译错误是:
warehouse.cc: In constructor ‘a4::warehouse::warehouse(std::string, std::string)’:
warehouse.cc:8: error: ‘class a4::warehouse’ has no member named ‘current_date’
warehouse.cc: In member function ‘void a4::warehouse::next_day()’:
warehouse.cc:12: error: ‘class a4::warehouse’ has no member named ‘current_date’
知道为什么它不承认current_date
是会员?这可能很简单,但我只需要几周时间学习c ++。
答案 0 :(得分:2)
我能看到的唯一可能是不你的标题是什么样的。确保您已在正确的目录中编辑正确的文件。
修复后,您会发现下一个错误是“无法将dates*
转换为date
”。这是因为您使用的是new
,而您不应该这样做。