Passing I/O functions to a class.

Or even, to be fancier:

void displaySomething (Stream & whichPort)
  {
  whichPort.println ("Hello world.");  
  }

void setup ()
  {
  Serial.begin (115200);
  displaySomething (Serial);
  }  // end of setup

void loop () { }