Using Serial in a Class

Hi.

I am having trouble figuring out how to go about creating a class for the SIM900 GSM module.

I want to be able to create a pointer that can point to either a Software Serial object or a Serial object.
The reasoning for doing this is so that when a user calls the constructor they have the choice of using the UART or to create a Software Serial port.

I want to avoid having to duplicate the code for writing to the serial port (hardware or software).
Ex.

SoftwareSerial mySerial(7,8);
bool usingSoftwareSerial = true;
if(usingSoftwareSerial)
{
     mySerial.begin(9600);
     mySerial.println("Text to Print");
}
else
{
     Serial.begin(9600);
     Serial.println("Text to Print");
}

So how should I go about creating a pointer that points to a Serial or Software Serial object based upon what the user chooses?

So how should I go about creating a pointer that points to a Serial or Software Serial object based upon what the user chooses?

Create a pointer of the same type as the common base class - Stream.

I want to be able to create a pointer that can point to either a Software Serial object or a Serial object.

Save yourself the headache... Ladyada uses a similar approach in her GPS lib. https://github.com/adafruit/Adafruit-GPS-Library

#if ARDUINO >= 100
  SoftwareSerial mySerial(3, 2);
#else
  NewSoftSerial mySerial(3, 2);
#endif
Adafruit_GPS GPS(&mySerial);