Mam dużo błędów w moim ostatnim projekcie (poker i black jack sim). Używam wektora do implementacji "rąk" w klasie blackJack i używam strukturalnego typu danych zadeklarowanego w innej klasie, która jest publicznie dziedziczona. Błąd, o który się martwię, to kompilator, którego używam, mówiąc, że nie deklaruję typu w wektorze.Błąd: wektor nie nazywa się typem
Blackjack plik nagłówka:
#ifndef BLACKJACK_H
#define BLACKJACK_H
#include <vector>
#include "card.h"
class blackJack: public cards
{
private:
vector <Acard> playerHand;
vector <Acard> dealerHand;
public:
blackJack();
void dealHands();
void hitOrStay();
void dealerHit();
int handleReward(int);
void printHands();
};
#endif
plik nagłówka karty (jest to black jack klasa dziedziczy z):
#ifndef CARD_H
#define CARD_H
const char club[] = "\xe2\x99\xa3";
const char heart[] = "\xe2\x99\xa5";
const char spade[] = "\xe2\x99\xa0";
const char diamond[] = "\xe2\x99\xa6";
//structured data to hold card information
//including:
// a number, representing Ace-King (aces low)
//a character, representing the card's suit
struct Acard
{
int number;
char pic[4];
};
// a class to hold information regarding a deck of cards
//including:
//An array of 52 Acard datatypes, representing our Deck
//an index to the next card in the array
//a constructor initializing the array indices to Ace-king in each suit
//a function using random numbers to shuffle our deck of cards
//13 void functions to print each card
class cards
{
private:
Acard Deck[52];
int NextCard;
public:
cards();
Acard getCard();
void shuffleDeck();
void cardAce(char[]);
void cardTwo(char[]);
void cardThree(char[]);
void cardFour(char[]);
void cardFive(char[]);
void cardSix(char[]);
void cardSeven(char[]);
void cardEight(char[]);
void cardNine(char[]);
void cardTen(char[]);
void cardJack(char[]);
void cardQueen(char[]);
void cardKing(char[]);
};
#endif
Nie jest źle. Ale proszę, nie rób tego. –
U może to zrobić, ale tylko w plikach źródłowych. Nie w nagłówkach, bo wtedy U będzie bardzo źle (mam na myśli spaghetti). – Hauleth
@LokiAstari dlaczego tego nie zrobić? Czy nie do tego służy "przestrzeń nazw"? lub czy problem z zalewaniem przestrzeni nazw wszystkim ze std? (Nie kłócę się, uczę się C++) –