wrote:
> I am currently using a class (Card) to represent a card in a deck of
> cards. The class has a constructor:
> Card::Card(int num, int su)
> {
> suit = su;
> number = num;
> }
>
> and I am trying to create multiple objects of that class (52 to be
> exact). As I am learning C++ (already know Java, Visual Basic and C#)
> I am not sure how to instantiate an object of that class. I am trying
> to use
>
> deck = gcnew Card(plcmnt[i], ((int)plcmnt[i] / 13));
>
> but I am running into problems. Any help is greatly appreciated
>
You should stop trying to program C++ like you program Java.
Card a_card(3, 3);
might be the 3 of diamonds, for instance.
Card deck[52];
for (int i = 0; i < 52; ++i)
deck[i] = Card(i%13, i/13);
would be one way to initialise a whole deck of cards.
You do not have to use new (or gcnew) to create objects in C++, and
generally speaking, you code will be a lot more efficient for it. This
is one of C++'s big advantages over Java.
john