Im writing a library, but I hit a brick wall right at the beginning.
I need to include an instance of the NewSoftSerial in the class, and I need that instance to be a class global.
In other languages you can define a variable as a class type, then later call the constructor. But in C++ it looks like both happen at the same time.
Under private globals I defined:
NewSoftSerial _printer;
Then in the constructor, I have
_printer(_RX_Pin, _TX_Pin);
But this dosnt seem to work one bit. I get an error of "error: no matching function for call to 'NewSoftSerial::NewSoftSerial()'"
I completely understand why because NewSoftSerial has no function called NewSoftSerial with no parameters.
But how does one get around this?
The library code is below.
#ifndef Thermal_h
#define Thermal_h
#include <NewSoftSerial.h>
#include <WProgram.h>
#include <WConstants.h>
class Thermal{
public:
Thermal(int RX_Pin, int TX_Pin);
private:
int _RX_Pin;
int _TX_Pin;
NewSoftSerial _printer;
};
#endif
#include <NewSoftSerial.h>
#include <WProgram.h>
#include <WConstants.h>
#include "Thermal.h"
Thermal::Thermal(int RX_Pin, int TX_Pin){
_RX_Pin = RX_Pin;
_TX_Pin = TX_Pin;
_printer(_RX_Pin, _TX_Pin);
}