I have a class Player which contains an instance variable: \
vector<Card> userCards;
In order to avoid any compilation errors I forward declared the class Card
. However now when I try to Build Solution I get an error saying
Card *: Unknown size.
Basically I am trying to create a Player
who contains a non-fixed number of cards, so I tried using a vector and now I cannot get it to work.
Player.h
#include <iostream>
#include <vector>
using std::string;
using std::vector;
#ifndef PLAYER_H_
#define PLAYER_H_
class Card;
class Player {
private:
vector<Card> userCards;
};
#endif
Card.h
#include <iostream>
using std::string;
#ifndef CARD_H_
#define CARD_H_
class Card {
private:
string name;
string type;
public:
Card(const string& name, const string& type);
};
#endif
I have a bunch of different functions that are not related, so I did not include them.