我正在尝试修复此错误,我仍在学习 cinder 和 c++。有人可以帮忙吗?先感谢您
错误:“'SerialHandler' 的构造函数必须明确初始化没有默认构造函数的成员 'serial'”
SerialHandler.h
class SerialHandler
{
public :
SerialHandler(){}; // <- error here
cinder::Serial serial; // <-
void setup();
bool isDone;
bool isonline;
};
串行处理器.cpp
#include "SerialHandler.h"
void SerialHandler::setup()
{
isDone =true;
try {
Serial::Device dev = Serial::findDeviceByNameContains("cu.usbmodem1411");
serial.Serial::create( dev, 115200);
console() << "Serial Connected" << std::endl;
isonline =true;
}
catch( ... ) {
console() << "There was an error initializing the serial device!" << std::endl;
isonline =false;
const vector<Serial::Device> &devices( Serial::getDevices() );
for( vector<Serial::Device>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
console() << "Device for MAIN?: " << deviceIt->getName() << endl;
}
}
}