I am working on a project where a ball is meant to bounce over the screen and bounce off a platform and other objects such as bricks.
However while ive been trying to do the collision am came over a seemly huge problem. When I pull into my function the coordinates of the platform
I get the following error:-
n:\project\brickwars\brickwars\b rickwars.cpp(294) : error C2446: '<=' : no conversion from 'int BrickKiller::* ' to 'int'
1> There is no context in which this conversion is possible
1>n:\project\brickwars\brickwars \brickwars.cpp(294) : error C2297: '<=' : illegal, right operand has type 'int BrickKiller::* '
It is referring to the if statement in the following code fragment
The following code is where it gets the coordinates from regarding the platform
BrickKiller::BrickKiller()//here we load our platform so we can use it.
speed = 4;
Could anyone give me some input how to fix this issue?
Last edited by blade.runner; 28-03-2012 at 01:16.
This is my function which controls the ball, only the collision am trying to do is a total fail lol.
void MovingBall:: Move( GWindow &Gwin)
// change the fill colour to red
// update the current position
//draw a red circle at the current position
if ( (yB<=60) || (yB>=445 ) )
if ( (xB<=85) || (xB>=450) ) //allow only ball to move inside set amount of the screen.
xdelta=-xdelta;//de-increment balls coorderates to make it move up the screen eg makes it bounce.
Gwin.destroy();//distroy ball if goes past platform.
Last edited by blade.runner; 28-03-2012 at 02:48.
(Original post by blade.runner)
If I take out the ampersand the debugger will flag another error and tell me I should have it. Yes i need to access the BrickKiller as that's where the platforms coordinates is located. I have spent hours trying to figure it out but I get no joy
I can see what your issue is and I am trying to explain it to you. You do not want to write &Class::member.
1> did you intend to use '.' instead?
If you do that, it guesses that you're trying to use a deep, dark and murky part of C++ called "pointer to member", which has this syntax:
But you don't want do do that. The class BrickKiller is just that, a class of objects and not an object itself, so you can't access its member variables unless you instantiate it like you would any other variable and access through the "." operator.
You don't write:
cout<< int <<endl;
cout<< string::size() <<endl;
cout<< BrickKiller::x <<endl;
string s="hello world";
cout<< x <<endl;
cout<< s.size() <<endl;
cout<< killer.x <<endl;
Last edited by roblee; 28-03-2012 at 03:07.