### Passing Array to a Function

Hey Everyone,
I recently ran into a problem when passing 3 arrays into a function that is supposed to move a spacestation sprite around a planet. Any help would be greatly appreciated.

 ``123`` ``````//Background.h // void Move(int,float[],float[],float[]);``````

 ``123456789101112`` ``````//Background.cpp // void Spacestation::Move(int c, float PlanetSize[], float GlobalPlanetX[], float GlobalPlanetY[]) { int theta = 0; GlobalStationX[c] = ((PlanetSize[c] + 20) * sin(theta)) + GlobalPlanetX[c]; GlobalStationY[c] = ((PlanetSize[c] + 20) * cos(theta)) + GlobalPlanetY[c]; theta++; if (theta >= 360) {theta = 0;} }``````

 ``123456`` ``````//Main.cpp // for(int c = 0; c < 3; c++) { stat.CheckDraw(c, global.ViewX, global.ViewY) stat.Move(c, planet.PlanetSize, planet.GlobalPlanetX, planet.GlobalPlanetY); }``````

 ``123456`` ``````Errors- error: no matching function for call to 'Spacestation::Move(int&, std::vector&, std::vector&, std::vector&)' note: candidate is: note: void Spacestation::Move(int, float*, float*, float*) note: no known conversion for argument 2 from 'std::vector' to 'float*'``````

Still fairly new to coding, and I'm not sure where to go from here.
Thanks!
Last edited on
PlanetSize, GlobalPlanetX, and GlobalPlanetY are all pointers to vector, so you have to access their elements with (*x)[n]. Be careful with that because the compiler will perfectly accept x[n] by itself, although it will do something entirely different from what you might otherwise expect.
Would you be able to give me a quick example to go off of? I'm still a bit confused.
Thank you
Bump for help.
You have defined `planet.PlanetSize`, `planet.GlobalPlanetX`, and `planet.GlobalPlanetY` as `vector<float>` not `float*` or `float[]`, right?

 ``1234`` ``````void Spacestation::Move(int c, vector PlanetSize, vector GlobalPlanetX, vector GlobalPlanetY); //or like this if you want it to run a bit faster (I avoid the details as you said you were new.) void Spacestation::Move(int c, const vector &PlanetSize, const vector &GlobalPlanetX, const vector &GlobalPlanetY);``````
Although a vector is like an array, they are not the same thing! (And there is no way to implicitly cast a `vector<T>` into a `T[]`.)