Tuesday, 27 August 2013

c++ multidimensional array multiple data types

c++ multidimensional array multiple data types

I am trying to create a multidimensional array in c++ where there's a
string and an int involved. I tried int test[1][2] = {{"a", 1}, {"b", 2},
{"c", 3}}; but g++ gave me the following:
example.cpp: In function 'int getServer(std::string)':
error: too many initializers for 'int [1][2]'
error: invalid conversion from 'const char*' to 'int' [-fpermissive]
I tried to use char test[1][2] as well for the initializer, but this
didn't work.

No comments:

Post a Comment