- #1
Saladsamurai
- 3,020
- 7
I decided I would try to create a relatively simple class in order to gain some more experience with thinking in an OOP mindset. But some things are hanging me up. I want to create a class of objects that represent a deck of cards. The number of cards should be able to change depending on what the user wants to do. A simple function that I will implement will be used to shuffle the deck. I figured to do this, I will use a vector object as the deck and then add some additional functionality to it. I am a little confused as to what the best way to do this is. I always hear that dynamic memory allocation is not good (when it can be avoided). This is presenting me with difficulty since I want to be able to initialize the Deck size.
How would you do this? Would you have a member function that takes in the number of cards as a parameter and then initializes the deck with it? Or is there a better way?
How would you do this? Would you have a member function that takes in the number of cards as a parameter and then initializes the deck with it? Or is there a better way?