我一直在谷歌搜索和阅读这个,并没有拿出一个答案呢,也许有人可以帮助我这个。C++在'{'标记之前的预期类名。继承
我想我的UserPile类能够从我的CardPile类访问数据成员和类成员函数。我一直在标题中提到错误。有人能解释发生了什么吗?我见过的继承教程看起来就像我的代码,除了我的代码是多个源代码文件。
//CardPile.h
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Card;
class CardPile
{
protected:
vector<Card> thePile;
//Card thePile[];
int pileSize;
public:
CardPile();
void insertCard(Card);
Card accessCard(int);
void displayPile();
void shuffle(); //shuffle the pile
void initializeDeck(); //create deck of cards
void deal(CardPile &, CardPile &);
void showHand();
bool checkForAce();
void discard(CardPile);
void drawCard(CardPile &);
};
//UserPlayer.h
using namespace std;
class UserPlayer: public CardPile
{
private:
//CardPile userPile;
public:
UserPlayer();
};
//UserPlayer.cpp
#include "UserPlayer.h"
#include "CardPile.h"
UserPlayer::UserPlayer()
{
}
我没有什么在这个UserPlayer类情况发生,但因为我将使用从基类的功能,所以我希望至少看到它编译之前,我开始写它。
感谢任何人的帮助。
请不要reedit破碎的标记... – 2010-01-25 01:33:22
@gf,你和我在同一时间编辑的问题,在6秒差异提交,但SO没有通知,因为它已经编辑,但刚刚提交,我发现你比较好,我将它回滚到你的修订版,但OP再次编辑到最好的版本,所以现在应该可以。 – YOU 2010-01-25 01:36:45
啊,好的。这些* some-second-diffs *有时很奇怪。 – 2010-01-25 01:40:53