문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top