How to initialize SoftwareSerial in a class in another Library


this might silly question have forgotten c/c++ classes long time ago. trying create library gprs shield , want include softwareserial object inside new object creating. header file include presume declaration of class member:

code: [select]

class sms
{
  public:
    sms();
    void begin();
    softwareserial smsserial;
   
  private: 
 
}


the constructor softwareserial have passed rx , tx pins. , want these parameters of function, maybe begin:

code: [select]

sms::sms()
{
  smsflags = b00000000;
}

void sms::begin(int rxpin, int txpin)
{
  smsserial = new softwareserial(rxpin,txpin); //<---- i'm supposed do?
}


not sure if should use "new"  or not.

i think 'new' work, avoided.
the 'new' allocate memory, makes harder detect when arduino has run out of ram memory.
you want rx , tx pin variables, have no choice , must use 'new'.

but why on earth want rx , tx pins variables? perhaps there different solution that.


Arduino Forum > Using Arduino > Programming Questions > How to initialize SoftwareSerial in a class in another Library


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support