[英]C++ inheritance of Arduino SoftwareSerial class
I am trying to create a new class that will inherit from SoftwareSerial
class (shown below in the code segment). 我正在尝试创建一个新类,该类将从
SoftwareSerial
类继承(如下代码段所示)。 When I declare the new class as class SerialGSM : public Stream
, it compiles. 当我将新类声明为
class SerialGSM : public Stream
,它将进行编译。 But when using class SerialGSM : public SoftwareSerial
, it fails with the message 但是当使用
class SerialGSM : public SoftwareSerial
,它失败并显示以下消息
expected class-name before'{' token
'{'令牌之前的预期类名
Following is the related code segment: 以下是相关的代码段:
#ifndef _SerialGSM_H
#define _SerialGSM_H
#include "Arduino.h"
#include <SoftwareSerial.h>
class SerialGSM : public SoftwareSerial {
public:
SerialGSM(int RXPin,int TXPin);
protected:
float payRate;
};
#endif /* not defined _SerialGSM_H */
Solved. 解决了。
Added 添加
#include <SoftwareSerial.h>
on the pde as well. 在PDE上也是如此。
#include <SerialGSM.h>
#include <SoftwareSerial.h>
SerialGSM cell(2,3);
void setup(){
cell.begin(9600);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.