We have a task to create a blackjack game.
Bellow is a simplified version of my code:
#include <iostream> #include <string> #include <time.h> using namespace std; class Deck { private: Card cards[52]; <-- HERE!! public: }; class Card { private: int suit; int number; public: int getSuit(); int getNumber(); void setCard(int suit, int number); }; int Card::getSuit() { return suit; } int Card::getNumber() { return number; } void Card::setCard(int s, int n) { suit = s; number = n; } class Players { private: Card PlayersCards[10]; public: /*Card getCard();*/ }; //Card Players::getCard() //{ // return; //} int main() { Players user; cin.get(); cin.get(); return 0; }
The problem is creating an array of objects. the compiler gives me the following errors:
Error C3646 'cards': unknown override specifier
Error C2143 with the syntax: missing ',' before '['
Error C2143 syntax error: missing ')' before ';'
Error C2238 unexpected token (s) preceding ';'
What is wrong with my code?
c ++ object arrays
user5714811
source share