<分区>
我遇到循环包含引用错误,我希望在 CardFactory 中使用 Deck 类型的对象,并在 Deck 中使用 CardFactory 类型的对象。关于如何解决此问题的任何提示?
//CardFactory.h
#ifndef CARDFACTORY_H
#define CARDFACTORY_H
#include "Deck.h"
#include <string>
using std::string;
class CardFactory {
public:
Deck getDeck();
static CardFactory* getFactory() {
static CardFactory singleton;
return &singleton;
}
};
#endif
//Deck.h
#ifndef DECK_H
#define DECK_H
#include <vector>
#include <iostream>
#include "CardFactory.h"
using std::ostream;
class Deck : public std::vector<Card*> {
friend ostream& operator<<(ostream& os, const Deck& dt);
Card* draw();
Deck(CardFactory* cf);
};
#endif