Sign in to follow this  
SirOnion

How is an INT an invalid array subscript?

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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[i].mass,planets[i].x,planets[i].y,planets[i].z,planets[i].radius,i);

Share this post


Link to post
Share on other sites
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[i].mass,planets[i].x,planets[i].y,planets[i].z,planets[i].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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this