简体   繁体   中英

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). When I declare the new class as class SerialGSM : public Stream , it compiles. But when using class SerialGSM : public SoftwareSerial , it fails with the message

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.

#include <SerialGSM.h>
#include <SoftwareSerial.h>
SerialGSM cell(2,3);
void setup(){  
 cell.begin(9600);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM