Note that there are some explanatory texts on larger screens.

plurals
  1. POc ++ String array issue
    primarykey
    data
    text
    <p>I'm just learning c++ coming from a Java background.</p> <p>Just playing around with simple classes now, but for some reason the following won't compile, when the same syntax compiles fine elsewhere:</p> <pre><code>class CardDealer { private: string suits[4]; string values[13]; bool cardTaken[4][13]; int getRand(int top); void getValidSuit(int *suit); void getValidCard(int suit,int *value); public: CardDealer(); string dealCard(); void resetDeck(); }; CardDealer::CardDealer(){ suits = {"hearts", "clubs", "spades", "diamonds"}; values = {"ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king"}; cardTaken = {{false,false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false,false}, {false,false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false,false}}; } </code></pre> <p>obviously this is just a part of the class so please don't yell at me for missing '}'s</p> <p>compiler chucks a wobbly when it hits the instantiations in the constructor, spits out errors like these:</p> <pre><code> 1>.\CardDealer.cpp(26) : error C2059: syntax error : '{' 1>.\CardDealer.cpp(26) : error C2143: syntax error : missing ';' before '{' 1>.\CardDealer.cpp(26) : error C2143: syntax error : missing ';' before '}' 1>.\CardDealer.cpp(27) : error C2059: syntax error : '{' 1>.\CardDealer.cpp(27) : error C2143: syntax error : missing ';' before '{' 1>.\CardDealer.cpp(27) : error C2143: syntax error : missing ';' before '}' 1>.\CardDealer.cpp(28) : error C2059: syntax error : '{' </code></pre> <p>line 26 is the one where I've instantiated suits (<code>suits = {</code>...)</p> <p>thanks for taking a look guys, much appreciated</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload