私はかなり新しくC++であり、今日まで自分のクラスを作成したことはありません。人々が正常に見直すためのコードを投稿するのは好きではありませんが、締め切りが早いので、コードをコンパイルする必要があります。C++でクラスを作成中にエラーが発生しました
-error:私は3つのエラーを取得する前の宣言よりも `RobotDeadReckoner :: RobotDeadReckoner()スロー() 'この行 で
- 複数のマーカー - エラー:RobotDeadReckoner::RobotDeadReckoner()' throws different exceptions - error: definition of implicitly-declared
RobotDeadReckoner :: RobotDeadReckonerの宣言を()'
-error:いいえRobotDeadReckoner::~RobotDeadReckoner()' member function declared in class
RobotDeadReckoner」
コードは以下の通りである:
#include <cmath>
#include "WPILib.h"
class RobotDeadReckoner
{//<---------------------Error
public:
float getX();
float getY();
float getHeading();
private:
Encoder *encoder1;//Encoder1 (Left Transmision while looking from the back)
Encoder *encoder2;//Encoder2 (Right Transmision while looking from the back)
int wheelRadius;//Wheel Radius (Center Wheel)
float axleWidthCenterToCenter;
int encoderTicksPerRotation;
int transmitionSprocketTeeth;
int wheelSprocketTeeth;
int ticksPerRotation; //ticks per rotation of wheel
float encoderTicks1;
float encoderTicks2;
float pi;
};
RobotDeadReckoner::RobotDeadReckoner()
{//<---------------------Error
wheelRadius = 4;//Wheel Radius (Center Wheel)
axleWidthCenterToCenter = 30+(7/8);
encoderTicksPerRotation = 360;
transmitionSprocketTeeth = 12;
wheelSprocketTeeth = 26;
ticksPerRotation = (wheelSprocketTeeth/transmitionSprocketTeeth)*encoderTicksPerRotation; //ticks per rotation of wheel
encoderTicks1 = encoder1->Get();
encoderTicks2 = encoder2->Get();
pi = atan(1)*4;
}
float RobotDeadReckoner::getX()
{
float x = wheelRadius*cos(getHeading())*(encoderTicks1+encoderTicks2)*(pi/ticksPerRotation);
return x;
}
float RobotDeadReckoner::getY()
{
float y = wheelRadius*sin(getHeading())*(encoderTicks1+encoderTicks2)*(pi/ticksPerRotation);
return y;
}
float RobotDeadReckoner::getHeading()
{
float heading = (2*pi)*(wheelRadius/axleWidthCenterToCenter)*(encoderTicks1-encoderTicks2);
return heading;
}
RobotDeadReckoner::~RobotDeadReckoner()
{ //<---------------------Error
}
私はそれが何かばかげたシンプルだと確信しています。私はC++については分かりませんが、どんな助けもありがとう!
getX()とgetY()の規約では、Xという名前の変数とYという名前の変数があると仮定しています。 – KevinDTimm