为类方法指定参数的类型会给出“没有匹配的函数调用”错误

时间:2019-03-17 19:00:36

标签: arduino arduino-c++

我正在尝试使用构造函数创建一个类,该类将接收enter image description here提供的dimmerLamp类型的参数。这是我的代码:

MyClass.h

#include <RBDdimmer.h>

#ifndef MYCLASS_H
#define MYCLASS_H

class MyClass {
  private:
    dimmerLamp redChannel;
    dimmerLamp greenChannel;
    dimmerLamp blueChannel;
    dimmerLamp yellowChannel;
  public:
    MyClass(dimmerLamp redChannel, dimmerLamp greenChannel, dimmerLamp blueChannel, dimmerLamp yellowChannel);
};

#endif

MyClass.cpp

#include <Arduino.h>
#include "MyClass.h"

MyClass::MyClass(dimmerLamp redChannel, dimmerLamp greenChannel, dimmerLamp blueChannel, dimmerLamp yellowChannel) {
  this->redChannel = redChannel;
  this->greenChannel = greenChannel;
  this->blueChannel = blueChannel;
  this->yellowChannel = yellowChannel;
}

但是当我尝试编译代码时,出现了指向MyClass.cpp中第4行的编译器错误,提示:

In file included from sketch/MyClass.h:1:0,
                 from sketch/MyClass.cpp:2:
/home/ovidiu/Arduino/libraries/RBDDimmer-master/src/RBDdimmer.h:61:3: note: candidate: dimmerLamp::dimmerLamp(int)
   dimmerLamp(int user_dimmer_pin);
   ^
/home/ovidiu/Arduino/libraries/RBDDimmer-master/src/RBDdimmer.h:61:3: note:   candidate expects 1 argument, 0 provided
/home/ovidiu/Arduino/libraries/RBDDimmer-master/src/RBDdimmer.h:38:7: note: candidate: constexpr dimmerLamp::dimmerLamp(const dimmerLamp&)
 class dimmerLamp 
       ^
/home/ovidiu/Arduino/libraries/RBDDimmer-master/src/RBDdimmer.h:38:7: note:   candidate expects 1 argument, 0 provided
/home/ovidiu/Arduino/libraries/RBDDimmer-master/src/RBDdimmer.h:38:7: note: candidate: constexpr dimmerLamp::dimmerLamp(dimmerLamp&&)
/home/ovidiu/Arduino/libraries/RBDDimmer-master/src/RBDdimmer.h:38:7: note:   candidate expects 1 argument, 0 provided
exit status 1
no matching function for call to 'dimmerLamp::dimmerLamp()'

为什么似乎要在该行中调用dimmerLamp::dimmerLamp()

0 个答案:

没有答案