I’m trying to implement a simple vector class, but I’m continually getting an error, and I cannot figure out why (though I increasingly suspect it is a stupid problem).
vector.h looks like this :
#ifndef PVECTOR_H
#define PVECTOR_H
#include "ofMain.h"
class PVector {
public:
//methods
void add(PVector v);
//constructor
PVector(float x, float y);
//variables
float x;
float y;
};
#endif
vector.cpp
#include "vector.h"
PVector::PVector(float _x, float _y)
{
x=_x;
y=_y;
}
void PVector::add(PVector _v){
x=x+_v.x;
y=y+_v.y;
}
testApp.h
#ifndef _TEST_APP
#define _TEST_APP
#include "ofMain.h"
#include "vector.h"
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
PVector velocity;
PVector position;
};
#endif
I’ve stripped out any instances in testApp.cpp, so this is essentially all I’ve got. When I compile I get the following error ::
error: no matching function for call to ‘PVector::PVector()’
So, what gives? I thought I had set up the constructor appropriately, but that seems to not be the case.