VS2013 cannot specify explicit initializer for arrays

I am trying create and initialze a two dimensional array as private member in a class. But I keep getting this error message "cannot specify explicit initializer for arrays" I tried several ways to bypass this problem but I keep getting errors.I am using VS2013.I'm hoping someone can help me out here.
Below is the code in question.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  using namespace std;
class Polybius
{
public:
	Polybius();
	vector<char> encode(string test);
	void decode(string test);

private:
	

	vector<char> digitSqueeze(string test);
	vector<char> alphaSqueeze(string test);
	
	void find_char(int& col, int& row , char& p);

	Array[5][5] = { { 'A', 'B', 'C', 'D', 'E' },
	{ 'F', 'G', 'H', 'I', 'J' },
	{ 'K', 'L', 'M', 'N', 'O' },
	{ 'P', 'Q', 'R', 'S', 'T' },
	{ 'U', 'V', 'W', 'X', 'Y' }};


};
closed account (48T7M4Gy)
No errors here!
Program ended with exit code: 0
Last edited on
Are you using VS2013?
closed account (48T7M4Gy)
No. I don't think your problem relates to the platform. Look carefully.
Last edited on
I still get the same error, I think it might be a VS2013 thing. At least that's what Ive read I tried some of the workarounds posted but nothing seems to help.
closed account (48T7M4Gy)
run using the cpp shell on this site.
Last edited on
That's a pretty cool feature did not know about it. But to answer your question, while your code runs perfectly on this shell and some other platforms . It WILL NOT compile on VS2013 I am looking for a workaround that will work with VS2013.You can google it there are several post about this on stackOverflow but it's only for one dimensional arrays. I tried to modify their workarounds to deal with a two dimensional arrays with no luck. I even posted the same question I posted here there but ofcourse the moderators had a fit about it since they though it was a question that had already been answered.
Found a way to by pass this, while I'm sure there are better ways this is the only way I can think of how. With my knowledge.
I created the two dimensional array in my header file
1
2
	char Array[5][5];


and I had to initialize it in the constructor inside the cpp file as so

1
2
3
4
5
6
7
8
9
10
11
Polybius::Polybius()
{

	Array[0][0] = 'A'; Array[0][1] = 'B'; Array[0][2] = 'C'; Array[0][3] = 'D'; Array[0][4] = 'E';
	Array[1][0] = 'F'; Array[1][1] = 'G'; Array[1][2] = 'H'; Array[1][3] = 'I', Array[1][4] = 'J';
	Array[2][0] = 'K'; Array[2][1] = 'L'; Array[2][2] = 'M'; Array[2][3] = 'N'; Array[2][4] = 'O';
	Array[3][0] = 'P'; Array[3][1] = 'Q'; Array[3][2] = 'R'; Array[3][3] = 'S'; Array[3][4] = 'T';
	Array[4][0] = 'U'; Array[4][1] = 'V'; Array[4][2] = 'W'; Array[4][3] = 'X'; Array[4][4] = 'Y';

}


Probably not the best way but nothing I read helps.
Last edited on
closed account (48T7M4Gy)
http://stackoverflow.com/questions/27882915/cant-specify-explicit-initializer-for-arrays
Last edited on
Kemort's code works with VS 2015 but not the versions before. Is there a reason why you don't want to upgrade to VS 2015?
Kemort tried that before posting here did not work for me.
Thomas I did not want to take the time to upgrade , thought there might be an easier solution. But, I am going to upgrade as soon as I have the time. For now I think I'm just gonna stick with the solution I found.
Thanks for your efforts guys.
Topic archived. No new replies allowed.