I am trying to do 2 functions to modify variables in a class. They won''t compile.
There are 2 ints, x and y. I am writing 1 function to return these values and 1 to set them:
Here''s the functions:
int playerclass::get_position(p,q)
int *p, *q; {
*p=X;
*q=Y;
return 0; }
/* for setting the player position at start of level.*/
int playerclass::set_position(p,q)
int q, p; {
X=p;
Y=q;
return 0; }
Here''s the class:
class playerclass
{
public:
int init();
int update_player();
/*int draw();*/
int get_position(p,q);
int set_position(p,q);
private:
int centerx, centery;
int X, Y;
float dX, dY;
int health;
int mass;
};
and here''s the error I get.
main.cpp:82: `p'' was not declared in this scope
main.cpp:82: `q'' was not declared in this scope
main.cpp:82: invalid data member initialization
main.cpp:82: (use `='' to initialize static data members)
main.cpp:83: `p'' was not declared in this scope
main.cpp:83: `q'' was not declared in this scope
main.cpp:83: invalid data member initialization
main.cpp: In member function `int playerclass::update_player()'':
main.cpp:109: warning: assignment to `int'' from `float''
main.cpp:109: warning: argument to `int'' from `float''
main.cpp:110: warning: assignment to `int'' from `float''
main.cpp:110: warning: argument to `int'' from `float''
main.cpp:114: warning: assignment to `int'' from `double''
main.cpp:114: warning: argument to `int'' from `double''
main.cpp: At global scope:
main.cpp:120: `p'' was not declared in this scope
main.cpp:120: `q'' was not declared in this scope
main.cpp:121: `int playerclass::get_position'' is not a static member of `class
playerclass''
main.cpp:121: initializer list being treated as compound expression
main.cpp:121: syntax error before `int''
main.cpp:123: ISO C++ forbids declaration of `q'' with no type
main.cpp:123: `Y'' was not declared in this scope
main.cpp:124: syntax error before `return''
main.cpp:127: `p'' was not declared in this scope
main.cpp:128: `int playerclass::set_position'' is not a static member of `class
playerclass''
main.cpp:128: initializer list being treated as compound expression
main.cpp:128: syntax error before `int''
main.cpp:130: ISO C++ forbids declaration of `Y'' with no type
main.cpp:130: invalid conversion from `int*'' to `int''
main.cpp:131: syntax error before `return''
What does this mean? Please help.
(I know what the things about floats and ints are, thats fine - not a problem)