SoftwareSerial as a private class member

Why can't I do like this?

class sim300 { private: SoftwareSerial* gsm; ...

and then

sim300::sim300(uint8_t RX, uint8_t TX, uint16_t speed) { gsm = new SoftwareSerial(RX, TX); gsm.begin(9600); }

Compiler error: gsm', which is of non-class type 'SoftwareSerial*'

I don't think you need the pointer operator in the declaration.

softwareSerial gsm; should work fine.

http://arduino.cc/en/Reference/SoftwareSerialConstructor

If I do not use pointer then an object needs to be initialized. But there is no empty constructor for SoftwareSerial.

If I try this

class sim300
{
private:
SoftwareSerial gsm(2,3);

I also get an error

sim300.h : expected identifier before numeric constant

Problem resolved. I had to use -> operator with pointer

sim300::sim300(uint8_t RX, uint8_t TX, uint16_t speed) { gsm = new SoftwareSerial(RX, TX); gsm->begin(speed); }