所以我有这个仓库类:
仓库.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
仓库.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++。