我一直在谷歌搜索和閱讀這個,並沒有拿出一個答案呢,也許有人可以幫助我這個。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