How is an INT an invalid array subscript?

Started by
3 comments, last by SirOnion 18 years, 11 months ago
80 C:\Documents and Settings\Jimmy\Desktop\Jim'sFortress\OpenGL\Jim'sPrograms\gravity.cpp invalid types `GLfloat[int]' for array subscript This is the line it will highlight: xPull[index] = acc * cos(xyAngle); This is how it was declared: GLfloat xPull[MAX_PLANETS]; (MaxPlanets was defined with #define)
Advertisement
Show us the line where "index" is defined.
-Scoot
index was a parameter in the function

function was created as:
void updatePull(GLfloat massPull,GLfloat xPull,GLfloat yPull,GLfloat zPull,GLfloat radiusPull,int index){...}

and called as:
for(int i = 0; i < MAX_PLANETS; i++)
tester.updatePull(planets.mass,planets.x,planets.y,planets.z,planets.radius,i);
Quote:Original post by SirOnion
index was a parameter in the function

function was created as:
void updatePull(GLfloat massPull,GLfloat xPull,GLfloat yPull,GLfloat zPull,GLfloat radiusPull,int index){...}

and called as:
for(int i = 0; i < MAX_PLANETS; i++)
tester.updatePull(planets.mass,planets.x,planets.y,planets.z,planets.radius,i);


Your paramter GLfloat xPull is wrong. It should be GLfFloat *xPull.
A to why I leave that as a exercise to a reader.
Oh! Wow I'm dumb, I forgot I have a parameter with the same name as the array. I just got it, sorry I'm dumb :) Thanks for the help though

This topic is closed to new replies.

Advertisement