Advertisement

Illigal indirection (c++)

Started by June 24, 2018 05:24 PM
2 comments, last by suliman 6 years, 5 months ago

Hi

Im having trouble with the syntax. 


	void stringPullPath(int inMoveClass, std::vector<void*> * path)	{
		int x, y;
		NodeToXY(&path[0], &x, &y);
      
       // other stuff here
      }

The function above seem to get a correct "path" (a pointer to a vector).

But the call to "NodeToXY" (which wants a "void *" as first argument) compiles like this, but what it actually recieves does seem to be corrupt or maybe the adress or something.

I need the argument passed to be the actual "void *" and I suspect my syntax is wrong here...

Thanks for any help!

I don't really use the std library much but it looks like you are passing in the address of the vector and then treating it like an array of std:vector<void *>. I wouldn't expect that to work.  Why don't you try passing in the vector by reference and then lose the & in the call to NodeToXY. I assume you want to pass in the first element of the vector.

Advertisement

Yay! That worked fine.

Thanks!

This topic is closed to new replies.

Advertisement