why class from my library does't print on uart?

Hello,
I can not find reason why the class from my library doesn’t print on uart?
Please would you explain me where is the fail?
Compiling works OK, uploading OK, blinking OK, but there are no chars on uart.

// file: example.ino

#include "Arduino.h"
#include "mylib.h"

mylib mylib2;

void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  digitalWrite(13, HIGH); // works OK
  mylib2.write('A');  // <-- does't print to uart
  delay(500);
  digitalWrite(13, LOW); // works OK
  mylib2.write('B'); // <-- does't print to uart
  delay(500);  
}
//EOF

// file: mylib.h

#ifndef MYLIB_H
#define MYLIB_H

#include "Arduino.h"

class mylib
{
  public:
  mylib();
  void write(uint8_t c);
};
#endif
//EOF

// file: mylib.cpp

#include "Arduino.h"
#include "mylib.h"

mylib::mylib()
{
  Serial.begin(9600);
}

void mylib::write(uint8_t c)
{
  Serial.write(c);
}
//EOF

Ask yourself: " when is my constructor called?" And "why does the Serial class have a method called begin()?"

Ask yourself: " when is my constructor called?" And "why does the Serial class have a method called begin()?"

While you are wondering about the significance of these questions, is your constructor called before, or after, the Serial instance of the HardwareSerial class is constructed?

If you don't KNOW, don't rely on the Serial instance existing or the hardware being ready for you to call Serial.begin().

http://www.gammon.com.au/forum/?id=12153#trap20

Amazing , the problem is solved. I ended up with code below. It works. Please is this recommended way?

// file: example.ino

#include "Arduino.h"
#include "mylib.h"

mylib mylib2;

void setup()
{
  pinMode(13, OUTPUT);
  mylib2.begin();
}

void loop()
{
  digitalWrite(13, HIGH); // works OK
  mylib2.write('A');  // prints to uart 'A'
  delay(500);
  digitalWrite(13, LOW); // works OK
  mylib2.write('B'); // prints to uart 'B'
  delay(500);  
}
//EOF
// file: mylib.h

#ifndef MYLIB_H
#define MYLIB_H

#include "Arduino.h"

class mylib
{
  public:
  mylib();
  void begin( void);  
  void write(uint8_t c);
};
#endif
//EOF
// file: mylib.cpp

#include "Arduino.h"
#include "mylib.h"

mylib::mylib()
{
}

void mylib::begin( void)
{
  Serial.begin(9600);
} 
  
void mylib::write(uint8_t c)
{
  Serial.write(c);
}
//EOF

Please is this recommended way?

Close. Your class' begin method should take an argument - the baud rate. Your class should not hard-code it. Other than that, yes, it is the proper way.