HAVING TROUBLE WITH ARRAYS

Here is the segment of code that sets up the matrix.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Matrix Declerations for Words
int LIBRARY(){
	const int pocetWord = 8;
	string[] Word = new string[pocetWord];
    Word[0] = "Adult";
    Word[1] = "Chocolates";
    Word[2] = "Church";
    Word[3] = "Circle";
    Word[4] = "Drink";
    Word[5] = "Drum";
    Word[6] = "Dung";
    Word[7] = "Ears";
    Word[8] = "Earth";
    Word[9] = "Egg";
    Word[10] = "Fungus";
    Word[11] = "Game";
    Word[12] = "Garden";
    Word[13] = "Gas";
    Word[14] = "Gate";
    Word[15] = "Gemstone";
    Word[16] = "Radar";
    Word[17] = "Rainbow";
    Word[18] = "Saddle";
    Word[19] = "Salt";
    Word[20] = "Sandpaper";
    Word[21] = "Sandwich";
    Word[22] = "Satellite";
    Word[23] = "Sun";
    Word[24] = "Sunglasses";
    Word[25] = "Surveyor";
    Word[26] = "Web";
    Word[27] = "Wheelchair";
    Word[28] = "Window";
    Word[29] = "Woman";
    Word[30] = "Worm";
    Word[31] = "X-ray";
	PLAY();
	return
}


there are errors for every single matrix decleration, so here is an EXAMPLE of the kind of errors i am getting.

1>MAIN.cpp(46): error C2440: '=' : cannot convert from 'const char [6]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(47): error C2440: '=' : cannot convert from 'const char [11]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(48): error C2440: '=' : cannot convert from 'const char [7]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(49): error C2440: '=' : cannot convert from 'const char [7]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(50): error C2440: '=' : cannot convert from 'const char [6]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(51): error C2440: '=' : cannot convert from 'const char [5]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(52): error C2440: '=' : cannot convert from 'const char [5]' to 'char'
1>          There is no context in which this conversion is possible
1>MAIN.cpp(53): error C2440: '=' : cannot convert from 'const char [5]' to 'char'
1>          There is no context in which this conversion is possible
change the declaration to
string* Word = new string[size]
The [] in string[] Word is your problem. That should be a * instead. new returns a pointer. Note that even if you had a normal static array, the syntax would be string Word[].

By the way, how come you allocate 8 strings and assign 32? That's not going to end well. Also, do you even need dynamic memory here? Using a const int implies that you don't..
simply change:
Word[1] = "Chocolates";
to:
string* Word = new string[Chocolates]

is that correct?
Last edited on
No.
Topic archived. No new replies allowed.