#include <iostream>
#include <cstdlib>
#include <cstdio>
usingnamespace std;
class Cards
{
public:
int ncardIndex; // 0-51.
int ncardValue; // assigned 2-14;; note that all cards have this defined for simplicity's sake. should not be access for JQKA.
string scardValue; // if Jack Queen King Ace;; note that the other chards will not have this defined.
string scardSuit; // Diamond, Club, Heart, Spade
bool bcardDrawn; // false if still in deck.
};
Cards* buildDeck()
{
Cards *cardDeck = NULL;
cardDeck = new Cards[52];
for (int i=0; i<52; i++)
{
// code for defining the objects here
}
return cardDeck;
}
int main()
{
Cards* deck = buildDeck();
cout << deck.scardValue[51];
return 0;
}
When I try to compile this, I get "error: conversion from 'Cards*' to non-scalar type 'Cards' requested". What am I doing wrong?
Also, where should i put the delete[] cardDeck? If I place it before the return cardDeck; the output becomes gibberish, but if I place it in main(), it tells me that cardDeck hadn't been defined within the scope.