Dynamic Class Object

I need to create a new class object that simulates a deck of cards. I've stripped out the entire code and am down to just this. I need to create an empty list where I can place 52 cards from another class. I can't even get off the ground.

int main()
1
2
3
4
int main()
{
  Deck my_deck();
}


deck.h
1
2
3
4
5
6
7
8
9
class Deck
{
public:
   Deck my_deck();
...
private:
   std::list<Card> my_deck;
   std::size_t my_deck_size;
};


deck.cpp
1
2
3
4
5
6
Deck::Deck ()
{
  my_deck_size = 52;
  Deck *my_deck[my_deck_size];
  my_deck = new Deck;
}


I get an error message about an incompatible type when I create the object. Can anybody set me straight? Thanks.
Line 3 in main() is not correct thanks to C++'s lineage with C. Anyway, the short of it is that line 3 does not do what you think it does; instead, you want Deck my_deck; // note no parens . If you are interested in why, google "C++ most vexing parse".

Thanks!
Topic archived. No new replies allowed.