I'm working on a forward and inverse kinematic model for a project and can't seem to fix this error.
I am very new to classes in C++ and have only used them in python in the past so sorry if it's a stupid problem.
An extract of my code is below, which is everything involved in what seems to give the error. The line showing the error is labelled, I have no idea what is going on and I can't seem to fix it.
#include <Servo.h>
class Leg{
public:
//The class's variables that all functions for this class can use
int PositionX;
int PositionY;
Servo Shoulder();
Servo Elbow();
Leg(int SP, int EP){ //-----------This line has the error!
// This is the constructor function
const int ShoulderPin = SP;
const int ElbowPin = EP;
PositionX = 0
PositionY = 0
Shoulder.attach(ShoulderPin);
Elbow.attach(ElbowPin);
}
void GoTo(float DemandS, float DemandE) {
// Sends this Leg to a certain position (could make this return a True when it is done)
// Inputs are in degrees (chould change)
Shoulder.write(DemandS);
Elbow.write(DemandE);
}
};
I have tried:
Giving the constructor function a variable type (void),
Moving the constructor out of the code block using Leg::Leg(....{.
Checking everywhere for any unclosed brackets, there are none.
Commenting out the Servo library and all of its uses.
I'd really appretiate any help as I feel like I've tried everything and must be missing something somewhere, contemplating doing this without classes, but it will be very annoying to do that. Thanks vey much :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…