casting - How to initialize static const char array for ASCII codes [C++] -


i want initialize static const char array ascii codes in constructor, here's code:

class card {  public:     suit(void)     {             static const char *suit[4] = {0x03, 0x04, 0x05, 0x06}; // here's problem         static const string *rank[ 13 ] = {'a', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'j', 'q', 'k'}; // , here. } 

however got whole lot of errors stating

  • 'initializing' : cannot convert 'char' 'const std::string *'

  • 'initializing' : cannot convert 'int' 'const std::string *'

please me! thank much.

you initializing 1 array of characters, want:

static const char suit[] = {0x03, 0x04, 0x05, 0x06}; static const char rank[] = {'a', '2', ...}; 

the forms using declaring arrays of strings , initializing them single strings. if want rank array of strings, initializers need in double quotes:

static const char* rank[] = {"a", "2", ...}; 

or:

static const std::string rank[] = {"a", "2", ...}; 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -