Static array of initialized members?
Probably not the best description; I'm building a simple class structure for my tokenizer and I want all initialized members of the class to be put into an array.
Unfortunantly; my compiler is yelling at me when I dump them into an array; could anyone point out how to actually accomplish this? Nothing I do seems to work t-t.
Code:
class Token {
public:
std::string token;
int opcode;
bool type;
static Token Tokens[32];
static int NTokens;
Token(std::string a, int b, bool c) {token = a; opcode = b; type = c; Tokens[NTokens++] = this;}
Token(char a, int b, bool c) {token[0] = a; token[1] = '\0'; opcode = b; type = c; Tokens[NTokens++] = this;}
};
I'm sure it's something simple; but I just don't see it.