So I have this warehouse class:
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();
}
}
And the compiler error im getting is:
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’
Any idea why its not recognizing current_date as a member? It’s probably pretty simple but I’m only a few weeks into learning c++.
The only possibility I can see is that this is not what your header looks like. Ensure that you’ve been editing the correct file in the correct directory.
When you’ve fixed that, you’ll find that your next error is “cannot convert
dates*todate“. This is because you’re usingnewwhere you should not be.