Hi,

I'm trying to define some consts to use as interface for a class...
The point is, I have to define const arrays of strings (that is a matrix), but after many years of C++ programming, this is actually the first time that I have such a task... so I need a refresh...

The following code:
Qt Code:
  1. const char CONNECTIONS_AMOUNT=2;
  2. const char DB[CONNECTIONS_AMOUNT-1][] = {"db1","db2"};
  3. const char USERNAME[CONNECTIONS_AMOUNT-1][] = {"root1","root2"};
  4. const char PASSWORD[CONNECTIONS_AMOUNT-1][] = {"admin","admin"};
  5. const char HOST[CONNECTIONS_AMOUNT-1][] = {"localhost","localhost"};
To copy to clipboard, switch view to plain text mode 
doesn't work and the compiler complains:
multidimensional arrays must have bounds for all dimensions except the first
so following a suggestion I found on the net:
Qt Code:
  1. const char CONNECTIONS_AMOUNT=2;
  2. const char DB[][CONNECTIONS_AMOUNT] = {"db1","db2"};
  3. const char USERNAME[][CONNECTIONS_AMOUNT] = {"root1","root2"};
  4. const char PASSWORD[][CONNECTIONS_AMOUNT] = {"admin","admin"};
  5. const char HOST[][CONNECTIONS_AMOUNT] = {"localhost","localhost"};
To copy to clipboard, switch view to plain text mode 
and now the compiler complains:
initializer-string for array of chars is too long
(perhaps because so it expects arrays of 2 chars, that is CONNECTIONS_AMOUNT).

So, what is the simple solution and the stupid mistake for this?
Thank you for your time