C ++ The expected class name before the '{' token. inheritance

I searched on Google and read about it and have not yet come up with an answer, maybe someone can help me with this.

I want my UserPile class to be able to access the data elements and members of the class from the CardPile class. I keep mentioning a mistake in the title. Can someone explain what is happening? The inheritance tutorials that I saw look just like my code, except mine, are a few source code files.

//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()
{

}

Nothing is happening for me in this UserPlayer class, because I will use functions from the base class, so I want to at least see its compilation before I start writing.

Thanks for the help.

+3
2

CardPile.h UserPlayer.h, CardPile .

, :

// CardPile.h:
#ifndef CARDPILE_H
#define CARDPILE_H

class CardPile {
    // ...
};

#endif

CardPile.h UserPlayer.cpp - UserPlayer.h #include "CardPile.h"

+4

UserPlayer.h #include CardPile.h - ?

+1

Source: https://habr.com/ru/post/1729837/


All Articles