Using serial.print to debug a library

Thanks for your help PaulS,

I've included the Hardware serial header in the file but I still get errors.

HardwareSerialClassExampleSplit.cpp.o: In function __static_initialization_and_destruction_0': C:\Users\Kb\AppData\Local\Temp\build6312645766259194773.tmp/HardwareSerialClassExampleSplit.cpp:5: undefined reference to MyLibrary::MyLibrary(HardwareSerial&)'
HardwareSerialClassExampleSplit.cpp.o: In function setup': C:\Users\Kb\AppData\Local\Temp\build6312645766259194773.tmp/HardwareSerialClassExampleSplit.cpp:8: undefined reference to MyLibrary::test()'

I had another window open and had a typo including the MyLibrary.cpp file vs the MyLibray.h file and that version compiles. I don't think that what I'm supposed to do though is it?

So the version which includes the .h file and spits out the above errors is:

#include "MyLibrary.h"
MyLibrary myLibrary(Serial);

void setup() {
  myLibrary.test();
}
void loop() {}

The one that compiled clean is:

#include "myLibrary.cpp"

MyLibrary myLibrary(Serial);

void setup() {

  myLibrary.test();  
}
void loop() {
  delay(10);
  myLibrary.test();

}

In both cases I modified the .cpp file to read

#include "HardwareSerial.h"
class MyLibrary {
  public:
    //pass a reference to a Print object
    MyLibrary( HardwareSerial &print ) { 
      printer = &print; //operate on the adress of print
      printer->begin(9600);
    }
    void test() {
      printer->println("Hello library with serial connectivity!");
    }
  private:
    HardwareSerial* printer;
};