0

だから私はこの倉庫クラスを持っています:

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++を学ぶのにほんの数週間しかかかりません。

4

1 に答える 1

2

私が見ることができる唯一の可能性は、これがヘッダーの外観ではないということです。正しいディレクトリで正しいファイルを編集していることを確認してください。

dates*それを修正すると、次のエラーは「に変換できません」であることがわかりますdate。これは、あるnewべきではない場所を使用しているからです。

于 2013-01-30T21:41:19.123 に答える