This program is frustrating me. I cannot for the life of me figure out what is causing this error message. It's the sort of thing where I fix one issue only to cause 10 more.
The compiler is giving me like 8 identical pairs of errors, one for each Ball.itsPosition.getX/Y call.
The first is "left of '.GetX' must have class/struct/union"
The second is "itsPosition' : is not a member of 'std::vector<_Ty>"
//point.cpp//
#include "Point.h"
#include "Ball.h" //cyclical dependency accounted for
#include <vector>
#include <math.h>
Point::Point (int x, int y) //deault x and y set to 0
{
itsX = x;
itsY = y;
}
Point::~Point(void)
{
}
//use the pythagorean theorum to determine the distance between two points.
//used to determine whether or not two Balls have collided
inline int Point::Distance (std::vector < Ball > Ball_1, std::vector < Ball > Ball_2)
{
return sqrt( ((Ball_2.itsPosition.GetX() - Ball_1.itsPosition.GetX()) * (Ball_2.itsPosition.GetX() - Ball_1.itsPosition.GetX())) + ((Ball_2.itsPosition.GetY() - Ball_1.itsPosition.GetY()) * (Ball_2.itsPosition.GetY() - Ball_1.itsPosition.GetY())) );
}
inline int Point::Distance(std::vector < Ball > Ball_1, class PlayerBall Ball_2) //the class is PlayerBall
{
return sqrt( ((Ball_2.itsPosition.GetX() - Ball_1.itsPosition.GetX()) * (Ball_2.itsPosition.GetX() - Ball_1.itsPosition.GetX())) + ((Ball_2.itsPosition.GetY() - Ball_1.itsPosition.GetY()) * (Ball_2.itsPosition.GetY() - Ball_1.itsPosition.GetY())) );
}
here is my ball.h class
#pragma once
#include "Point.h" //because Ball is a composition
#include "Velocity.h"
#include <vector>
class Ball {
public:
Ball(int, int);
~Ball();
void WallCollision ();
void ApplyForce ();
//accessor methods
void SetExistence (bool truth) { itsExistence = truth; }
int GetExistence () const { return itsExistence; }
private:
Point itsPosition;
Velocity itsVelocity;
bool itsExistence;
};
Does anyone know what syntax error I'm making here.