Dev-C++ Compiler [error] problem.....

This line of code was working, but now it is through me compiler errors that I am not exactly use to seeing.

[error] invalid operands of types 'int[2][2]' and 'int' to binary 'operator*'
[error] invalid operands of types 'int[2][2]' and 'double' to binary 'operator*'
[error] invalid operands of types 'float' and 'int[2][2]' to binary 'operator*'


What's below is not my whole code, just the variables and the actual code (It was working before, and compiled....I didnt make changes to that specific code...


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

HourPy[2][2][2]; string eArray[8]; float HrWkd[8]; float Gpay[8]; float Npay[8]; float TxRate; float TaxRt[8]; float addGP[8]; float GPresults=0;
float taxRT; float OtHours[8]; float StTime[8]; int ctr11=0; string name = "Enter the hours worked by "; float taxPD[8]; string space = "  "; int ctr4 = 0;
string phrase = "The total hourly pay expenses for the Slate Rock & Gravel Co. this week is ";

    for(int ctr0=0; ctr0 <= 7; ctr0++)
         {
          if(HrWkd[ctr0] > 40)
	   {
	     OtHours[ctr0] = HrWkd[ctr0] - 40;
	     StTime[ctr0] = HourPy[ctr0] * 40;
	     OtHours[ctr0] = HourPy[ctr0] * 1.5 *OtHours[ctr0];
	     Gpay[ctr0] = StTime[ctr0] + OtHours[ctr0];
			   }
	        else
   	           { Gpay[ctr0] = HrWkd[ctr0] * HourPy[ctr0]; }
          }
Last edited on
It seems that HourPy has no type. I assume it needs to be int HourPy[2][2][2]? Later, you use it like this: HourPy[ctr0]. You can't multiply that with 1.5!
At line 2, your HourPy[2][2][2] which is 3 dimension array but in line 11, your HourPy[ctr0] used as single dimension array which will then create a declaration conflict.....
I think I inlcuded a copy of the code above when i was changing float HourPy[2][2][2] to int HourPy[2][2][2]. It orginally had a value, and since then I have added a value to my variables. Before I had even done much to the code the code was compiling. The only thing I did different was I created 2 extra for loops at the top of my code because It's a pre-req to include the HourPy in it's own seperate 2x2x2 array where only 1 space is being occupied. I havent leared about pointers or references or vectors though.
That is not a problem as float and int can use for each other which mean float * float and you store in int you still can get answer. The problem you face for now is the compiler cant detect HourPy[x] as for your declaration is HourPy[x][y][z] and you times it with operator * which is then give you the error...
OMG, I am such a dummy....I didnt even bother to look at that because I was so concerned with other errors that the compiler was giving me. Ill change those lines, and see what I get.....
As you change those error variable i think all the error above should be solved..... And sorry for my broken english XD
Topic archived. No new replies allowed.