c++ class as paramater from within the class

Started by
0 comments, last by Telastyn 15 years, 7 months ago
I tried a few times to put this into words, none of them made any sense. Basically, I am trying to call a function with a class parameter, the catch is the class being passed is the class I am calling it in. Here is a code example (I know the code doesn't work, this is a quick example)

class a
{
   int x,y,func(template);
}

int a::func(template obj)
{
   //do stuff
}

class b
{
   int function(a)
}
int b::function(a obj)
{
   a(this);
}
I am unable to pass "this" to the function, it tells me this every time I try to access something: error: request for member `x' in `obj', which is of non-class type `player*' x being the member, obj being the parameter name, and player being the class that is being passed. How would do this?
I would rather you disagree with me then accept everything I say. Think for yourself!
Advertisement
By passing the correct parameter?

this is a pointer type. Your arguments (as you describe them) are not. Either dereference the pointer or make the method take a pointer.

This topic is closed to new replies.

Advertisement