Ok I keep getting these anoying errors and I'm not exactly sure where they are coming from, I have several objects I am using it seems to be a problem of pass by value and pass by reference (not by a pointer but similar it's treated differently).
Errors
Headers
fighters.hpp
ball.hpp
objects.hpp
geometry.hpp
Offending code:
I assume the problem is that Throw() etc must be past by value instead of reference right? If I change this the compilor has a new set of things to bitch about.
What is the deal here.. Point(Point) I already used Point(int, int, int) to create the point, WTF is it looking for Point(Point). To be honest these errors make little sense unless I'm missing something.
Cyb
Errors
Code:
fighters.cpp: In member function `void Fighter::Show()':
fighters.cpp:46: no matching function for call to `Ball::Throw(Point)'
ball.hpp:16: candidates are: void Ball::Throw(Point&)
fighters.cpp:48: no matching function for call to `Ball::Throw(Point)'
ball.hpp:16: candidates are: void Ball::Throw(Point&)
fighters.cpp:81: no matching function for call to `Fighter::AimAt(Point)'
fighters.hpp:40: candidates are: u8 Fighter::AimAt(Point&)
fighters.cpp: In member function `u8 Fighter::AimAt(Point&)':
fighters.cpp:144: no matching function for call to `Fighter::WalkTo(Point)'
fighters.hpp:42: candidates are: void Fighter::WalkTo(Point&)
make: *** [fighters.o] Error 1
Headers
fighters.hpp
Code:
class Fighter : public Object
{
public:
Fighter(Arena *);
Fighter(Arena *,int);
~Fighter();
u8 AimAt(Point &);
Point FindNearest();
void WalkTo(Point &);
void Show(void);
u16 Force;
u32 Flags;
private:
Point Target;
int Range;
u16 Health;
u8 State;
u16 FrameP;
Ball *SBl;
};
ball.hpp
Code:
#ifndef _BALL_H_
#define _BALL_H_
#include "object.hpp"
class Ball : public Object
{
public:
Ball(Arena *);
Ball(Object *);
~Ball();
void Show(void);
void Throw(Point &);
private:
Object *MyHolder;
Point M;
};
#endif
objects.hpp
Code:
#ifndef _OBJECT_H_
#define _OBJECT_H_
#include "frame.hpp"
#include "geometry.hpp"
//#include "arena.hpp"
class Arena;
class Object
{
public:
Object(Arena *);
Object(Arena *, Point &);
Object(Arena *,Frame *);
Object(Arena *,Frame *, Point &);
~Object();
void Xlate( Point &);
void Move( Point &);
Point At(void);
void Show(void);
Arena * MyArena;
Point Location;
Frame *Graph;
private:
void ObjectInit(void);
u8 Direction;
u8 Sprite;
};
#endif
geometry.hpp
Code:
// 100 units is 1 meter
// this gives 21000km approximately as the greatest distance
class Point
{
public:
Point();
Point(int, int, int);
Point( Point &);
Point( Point *);
~Point() {;}
Point operator+=(Point);
//Point operator+(Point);
Point operator*=(int);
//Point operator*=(Point);
Point operator/=(int);
//Point operator*(int);
//Point operator*(Point);
//Point operator/(int);
u8 operator==(Point);
u8 operator!=(Point);
int Diff(Point);
int X, Y, Z;
};
// gravity is 9.81 m/s^2
extern Point Gravity;
extern Point Origin;
Offending code:
Code:
<46> SnowBall->Throw(Point(-Force, 0, 0));
<48> SnowBall->Throw(Point(Force, 0, 0));
<81> if (AimAt(FindNearest()))
<144> WalkTo(Point(Location.X + abs(Diff), Location.Z + Diff, P.Y));
Code:
fighters.cpp: In member function `void Fighter::Show()':
fighters.cpp:46: no matching function for call to `Point :: Point(Point)'
geometry.hpp:14: candidates are: Point :: Point(Point*)
geometry.hpp:13: Point:: Point(Point&)
fighters.cpp:46: initializing argument 1 of `void Ball::Throw(Point)'
fighters.cpp:48: no matching function for call to `Point :: Point(Point)'
geometry.hpp:14: candidates are: Point :: Point(Point*)
geometry.hpp:13: Point :: Point(Point&)
fighters.cpp:48: initializing argument 1 of `void Ball::Throw(Point)'
fighters.cpp:81: no matching function for call to `Point :: Point(Point)'
geometry.hpp:14: candidates are: Point :: Point(Point*)
geometry.hpp:13: Point :: Point(Point&)
fighters.cpp:81: initializing argument 1 of `u8 Fighter::AimAt(Point)'
fighters.cpp: In member function `u8 Fighter::AimAt(Point)':
fighters.cpp:148: no matching function for call to `Point:: Point(Point)'
geometry.hpp:14: candidates are: Point :: Point(Point*)
geometry.hpp:13: Point :: Point(Point&)
fighters.cpp:148: initializing argument 1 of `void Fighter::WalkTo(Point)'
make: *** [fighters.o] Error 1
What is the deal here.. Point(Point) I already used Point(int, int, int) to create the point, WTF is it looking for Point(Point). To be honest these errors make little sense unless I'm missing something.
Cyb
Last edited: