Class A type in Class B's private?

I'm currently planning a game that involves a deck of cards that are placed in a game board, which is also a class. The idea is something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Card.hh
public:
...
private:
int number_;
bool colored_;
bool empty_;
...

Deck.hh
public:
...
Card newCard(); //Returns one card from the vector deck.
private:
vector<Card> deck_;


And in the function where these are called, it should go ideally like this:

1
2
Card newCard = deck.newCard();
board.placeCard(4, 6, newCard); //board is its own class 


Is this possible to do so? To have another class' type in another's? I admit I'm kinda out of the loop here, so can I just include Card.hh into Deck.hh and have it working?
Yes.

Q: What does the compiler need to know in order to compile this:
1
2
3
4
5
6
7
8
// ?

int main()
{
  Foo x;

  return 0;
}

A:
1. How many bytes to reserve from stack for x, i.e. sizeof(Foo)
2. Whether Foo has default constructor.

Linker will later link the calls to constructor and destructor to their implementations.

In order to know the size of Foo one has to know the sizes of its member variables. The only difference between basic and complex types is that definition of the complex types has to be provided.
Looks completely plausible to me.
Topic archived. No new replies allowed.