C++ “没有构造函数实例”;RobotDriveSwerve::RobotDriveSwerve“;匹配参数列表--参数类型为

C++ “没有构造函数实例”;RobotDriveSwerve::RobotDriveSwerve“;匹配参数列表--参数类型为,c++,C++,我正在浏览并尝试创建我的swerveDrive,但是我遇到了一个问题,构造函数与参数列表不匹配 我已经尝试过进入这个类并更改可能被请求的参数 GenericEnclosure.h class GenericEnclosure : public SwerveEnclosure { public: GenericEnclosure( std::string name, frc::SpeedController& m_moveMotor,

我正在浏览并尝试创建我的
swerveDrive
,但是我遇到了一个问题,构造函数与参数列表不匹配

我已经尝试过进入这个类并更改可能被请求的参数

GenericEnclosure.h

class GenericEnclosure : public SwerveEnclosure {
public:

    GenericEnclosure(   std::string name,
                frc::SpeedController& m_moveMotor,
                frc::SpeedController& m_turnMotor,
                rev::CANEncoder& m_encoder,
                double m_gearRatio);
    ~GenericEnclosure();

};
RobotDriveSwerve.h文件

class RobotDriveSwerve
{
public:
    RobotDriveSwerve(SwerveEnclosure* frontLeftWheel,
                     SwerveEnclosure* frontRightWheel,
                     SwerveEnclosure* rearLeftWheel,
                     SwerveEnclosure* rearRightWheel,
                     double width, double length);
    virtual ~RobotDriveSwerve() = default;
.cpp文件

  //All Drive Motors
  rev::CANSparkMax m_leftFrontDriveMotor{1, rev::CANSparkMax::MotorType::kBrushless};
  rev::CANSparkMax m_leftBackDriveMotor{2, rev::CANSparkMax::MotorType::kBrushless};
  rev::CANSparkMax m_rightFrontDriveMotor{3, rev::CANSparkMax::MotorType::kBrushless};
  rev::CANSparkMax m_rightBackDriveMotor{4, rev::CANSparkMax::MotorType::kBrushless};

  //All Turn Motors
  rev::CANSparkMax m_leftFrontTurnMotor{5, rev::CANSparkMax::MotorType::kBrushless};
  rev::CANSparkMax m_leftBackTurnMotor{6, rev::CANSparkMax::MotorType::kBrushless};
  rev::CANSparkMax m_rightFrontTurnMotor{7, rev::CANSparkMax::MotorType::kBrushless};
  rev::CANSparkMax m_rightBackTurnMotor{8, rev::CANSparkMax::MotorType::kBrushless};

  //All Drive Encoders
  rev::CANEncoder m_leftFrontDriveEncoder = m_leftFrontDriveMotor.GetEncoder();
  rev::CANEncoder m_leftBackDriveEncoder = m_leftBackDriveMotor.GetEncoder();
  rev::CANEncoder m_rightFrontDriveEncoder = m_rightFrontDriveMotor.GetEncoder();
  rev::CANEncoder m_rightBackDriveEncoder = m_rightBackDriveMotor.GetEncoder();

  //All Turn Encoders
  rev::CANEncoder m_leftFrontTurnEncoder = m_leftFrontTurnMotor.GetEncoder();
  rev::CANEncoder m_leftBackTurnEncoder = m_leftBackTurnMotor.GetEncoder();
  rev::CANEncoder m_rightFrontTurnEncoder = m_rightFrontTurnMotor.GetEncoder();
  rev::CANEncoder m_rightBackTurnEncoder = m_rightBackTurnMotor.GetEncoder();

 const double GEAR_RATIO = (1988/1.2);
const double L = 24.5;
const double W = 20.5;

//Enclosure initialization
        GenericEnclosure swerveEnclosure1{"enc 1", m_rightFrontDriveMotor, m_rightFrontDriveMotor, m_rightFrontTurnEncoder,GEAR_RATIO};
        GenericEnclosure swerveEnclosure2{"enc 2", m_leftFrontDriveMotor, m_leftFrontTurnMotor, m_leftFrontTurnEncoder, GEAR_RATIO};
        GenericEnclosure swerveEnclosure3{"enc 3", m_leftBackDriveMotor, m_leftBackTurnMotor, m_leftBackTurnEncoder, GEAR_RATIO};
        GenericEnclosure swerveEnclosure4{"enc 4", m_rightBackDriveMotor, m_rightBackTurnMotor, m_rightBackTurnEncoder, GEAR_RATIO};

//Swerve Drive initialization
        RobotDriveSwerve swerveDrive{swerveEnclosure1, swerveEnclosure2, swerveEnclosure3, swerveEnclosure4, W, L};

错误来自这一行
robotdriveswervedrive{swerveEnclosure1,swerveEnclosure2,swerveEnclosure3,swerveEnclosure4,W,L}并引发此错误
没有构造函数“RobotDriveSwerve::RobotDriveSwerve”的实例与参数列表匹配--参数类型为:(GenericEnclosure、GenericEnclosure、GenericEnclosure、GenericEnclosure、const double、const double)
。一切都很好,但这是唯一一行。很抱歉,所有的代码,但它是一个相当大的类来正确构建。非常感谢所有能够提供帮助的人

机器人驾驶转向
构造函数正在寻找指针。您需要使用“地址”操作符。改变

RobotDriveSwerve swerveDrive{swerveEnclosure1, swerveEnclosure2, swerveEnclosure3, swerveEnclosure4, W, L};


RobotDriveSwerve
构造函数正在寻找指针。您需要使用“地址”操作符。改变

RobotDriveSwerve swerveDrive{swerveEnclosure1, swerveEnclosure2, swerveEnclosure3, swerveEnclosure4, W, L};


RobotDriveSwerve
的构造函数中,当您在编译器产生错误的行中提供引用时,需要指向类
GenericEnclosure
的指针。

RobotDriveSwerve
的构造函数中,当您提供编译器产生错误的行中的引用。

构造函数decl说前四个参数是指针。您正在传递具体对象,并且没有转换运算符。简而言之,错误消息会准确地告诉您问题所在。与此无关,如果这些定义实际上是全局的,那么您可能会遇到另一个完全不同的问题(静态初始化)。
RobotDriveSwerve
的构造函数会获取您传递给对象实例的指针。关于此错误有什么不清楚的地方?当您将
GenericEnclosure
(不是指针)传递给构造函数时,构造函数接受类型为
SwerveEnclosure*
(指针)的参数。构造函数decl说前四个参数是指针。您正在传递具体对象,并且没有转换运算符。简而言之,错误消息会准确地告诉您问题所在。与此无关,如果这些定义实际上是全局的,那么您可能会遇到另一个完全不同的问题(静态初始化)。
RobotDriveSwerve
的构造函数会获取您传递给对象实例的指针。关于此错误有什么不清楚的地方?当您向构造函数传递
GenericEnclosure
(不是指针)时,构造函数接受类型为
SwerveEnclosure*
(指针)的参数。这取决于类对这些指针的处理方式。。。我更愿意修改构造函数以接受常量引用;但是如果类
RobotDriveSwerve
存储了这些指针,那么解决方案就是传递智能指针。无论如何,我们没有看到
RobotDriveSwerve
的实现。只是做了更改,这次编译的代码。感谢您的帮助,这取决于类如何处理这些指针。。。我更愿意修改构造函数以接受常量引用;但是如果类
RobotDriveSwerve
存储了这些指针,那么解决方案就是传递智能指针。无论如何,我们没有看到
RobotDriveSwerve
的实现。只是做了更改,这次编译的代码。谢谢你的帮助