Hello people, I am making c++ game with SFML engine. Right now I'm making explosion rotation function, witch would let me set rotation in other class file.
I have class explosion_effect in witch i have (header file):
1 2
vector2 rotation(int x, int y);
void rotate(int xd, int yd);
rotation is a vector2 class method, witch has two parameters: x and y; It represents 2d objects...
In cpp file i do:
1 2 3 4 5 6 7 8 9 10 11 12 13
void explosion_effect::rotate(int xd, int yd) {
rotation(xd,yd);
}
//and in function where i add explosions:
void explosion_effect::add(vector2 add1)
{
explosion exp;
//...
exp.rotate(rotation);
explosions.push_back(exp);
}
and the error is:
function call missing argument list; use '&explosion_effect::rotation' to create a pointer to member
but if i add parameters to line like this: exp.rotate(rotation(x,y));
it tells that x and y are undeclared.
If someone understand this sh*t, please help, I got caught on this for the third day and I can't solve... And the problem can be everywhere, even in header file, not only in add function I think... :(
vector2 rotation(int x, int y);
void rotate(int xd, int yd);
Take a look at: exp.rotate(rotation);
"rotation" is expanded to "explosion_effect::rotation" and is recognized as a function, not as two parameters.
explosion_effect::rotation only takes two parameters.
Thanks EssGeEich, I solved this :)
MikeyBoy, I make this function with x and y parameters, so I could make one object to rotate at other from them positions. I can also rotate object by setting x and y from 1 to -1 :)
Well, in the OP's original code, s/he was attempting to use it as a function pointer. Then, they tried using it as a function call, with 2 undefined parameters. From context, it appeared that the OP was attempting to call rotation() and then pass the return value into rotate(), and was having trouble understanding why it wasn't working.
I was seeing whether the OP actually understood how to call functions with parameters.
In fact "rotation" is a parameter in that context.
From context, it appeared that the OP was attempting to call rotation() and then pass the return value into rotate()
I'm pretty certain that the OP wasn't attempting to use it as a function pointer - s/he was fairly obviously attempting to call rotation() as a function, and use the return value as a parameter to rotate().
This is made even more clear by the fact that the OP then added parameters to the attempted call to rotation():
but if i add parameters to line like this: exp.rotate(rotation(x,y));
vector2 rotation Should be without parameters (I made a mistake here).
I made rotate function with parameters, so I could write the rotation of object in other cpp file like that: object.rotate(x,y) or something like that. :)
Thanks for your tips, I respect your opinion and I'm not very advanced c++ programmer, so your advice is very valuable for me. :)