Pergunta

I'm trying (or rather struggling) to create a little Blackjack game. After some JavaScript courses and a few little projects I decided to switch to C++ and found it a little bit problematic, here is my code:

http://pastebin.com/raw.php?i=4MgC1VcD

For many of you this code can be just crappy, but it makes me really happy to code, even if it doesn't work as I wanted it to :) This is what i get:

http://i.stack.imgur.com/HpyvC.png

Foi útil?

Solução

You need to define the method random as inline.

inline int random(int nMin, int nMax)
{ 
    return rand() % (nMax - nMin + 1) + nMin; 
}

Otherwise, each translation unit that includes the header will generate code for it.

Either this, or just declare it in the header and define it in an implementation file.

Also, declare globals as extern:

extern std::string sSuits[];
extern std::string sRanks[];

and initialize them in an implementation file.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top