我具有以下结构的三个文件
- src/
- events
- ...
- Event.cpp
- Event.h
- EventPtr.h
- ...
问题是#include Event.h
中的EventPtr.h
似乎不起作用。这是代码:
#ifndef POKERSIMULATIONSINCPP_EVENT_H
#define POKERSIMULATIONSINCPP_EVENT_H
#include <iostream>
#include "game/Table.h"
#include "players/Player.h"
namespace events {
enum TargetType {
Dealer, Table, None, Players
};
class Event {
private:
TargetType target = None;
std::string description = "Base event class";
bool done = false;
public:
~Event();
Event();
TargetType getTarget();
std::string getDescription();
bool getDone();
};
}
#endif //POKERSIMULATIONSINCPP_EVENT_H
#include "Event.h"
#include <iostream>
namespace events {
TargetType Event::getTarget() {
return target;
}
std::string Event::getDescription() {
return description;
}
bool Event::getDone() {
return done;
}
Event::~Event() = default;
Event::Event() = default;
}
#ifndef POKERSIMULATIONSINCPP_EVENTPTR_H
#define POKERSIMULATIONSINCPP_EVENTPTR_H
#include <memory>
#include "events/Event.h"
namespace events {
typedef std::shared_ptr<Event> EventPtr;
}
#endif //POKERSIMULATIONSINCPP_EVENTPTR_H
哪个出现以下错误:
D:/PokerSimulationsInCpp/src/events/EventPtr.h:13:29: error: 'Event' was not declared in this scope
typedef std::shared_ptr<Event> EventPtr;
我也尝试过EventPtr.h
#ifndef POKERSIMULATIONSINCPP_EVENTPTR_H
#define POKERSIMULATIONSINCPP_EVENTPTR_H
#include <memory>
#include "events/Event.h"
#include "Event.h"
namespace events {
typedef std::shared_ptr<events::Event> EventPtr;
}
#endif //POKERSIMULATIONSINCPP_EVENTPTR_H
哪个出现以下错误:
D:/PokerSimulationsInCpp/src/events/EventPtr.h:14:37: error: 'Event' is not a member of 'events'
typedef std::shared_ptr<events::Event> EventPtr;
有人知道怎么回事吗?
答案 0 :(得分:1)