Blank Custom Component does not compile

Hi!

I try to build custom component for a DS3502 chip. But I already fail to build an empty custom component as desrcibed at Custom Output — ESPHome :

#include "esphome.h"
using namespace esphome;

class MyDs3502 : public Component, public FloatOutput {
 public:
  void setup() override {
    // This will be called by App.setup()
  }

  void write_state(float state) override {
    // state is the amount this output should be on, from 0.0 to 1.0
    // we need to convert it to an integer first
  }
};

This does oviously nothing. But including it like

esphome:
  name: esp-01s-solar-board
  libraries: 
    - Wire
    - SPI
    - adafruit/Adafruit BusIO@^1.11.6
    - adafruit/Adafruit DS3502@^1.0.1
  includes:
    - MyDs3502.h

does not compile:

Compiling /data/esp-01s-solar-board/.pioenvs/esp-01s-solar-board/src/main.cpp.o
In file included from src/main.cpp:61:
src/MyDs3502.h:4:55: error: expected class-name before '{' token
    4 | class MyDs3502 : public Component, public FloatOutput {
      |                                                       ^
src/MyDs3502.h:10:8: error: 'void MyDs3502::write_state(float)' marked 'override', but does not override
   10 |   void write_state(float state) override {
      |        ^~~~~~~~~~~
*** [/data/esp-01s-solar-board/.pioenvs/esp-01s-solar-board/src/main.cpp.o] Error 1
========================== [FAILED] Took 2.19 seconds ==========================

What am I doing wrong?

Best regards

Pascal