I'm currently taking a programming class, and I've got an assignment to write a basic Blackjack game in C++. I'm having some trouble writing the code I need to shuffle the deck before play can actually begin, and I was hoping someone would know how to help.
I'm starting by defining the deck as an array of strings, so I have:
string deck[52] = {"2","2"... etc. etc.}
In theory, I have the random_shuffle function called correctly, at least I think so:
When I run this in Visual Studio (by the way, pardon the "->" instead of a period, VS seems to like that better; the compiler didn't accept periods), it returns the array in the exact same order than I used to initially declare the deck.
The use of vector instead of array has no bearing on whether shuffle works or not.
In general, vector is the default container to use if you're not sure what to use. It has some nice properties.
Arrays aren't really objects, they're sequences. And they're a little bit weird. For example, there's no way to pass them across functions, you end up passing a pointer, and so you loose the size. As you'll be doing object oriented programming, it's better to use an object container rather than an array.