我正在尝试使用构造函数创建一个类,该类将接收提供的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()
?