Separating classes in header and source causes build errors [closed]

The following code snippets are intentionally made simple only to illustrate the problem. There are two cases I want to show here. The first one in which all code is put in a single file as follows.

#include <iostream>

class Base
{
protected:
    double data;

public:
    Base(double data);
};

Base::Base(double data = 10) : data{data}{}


class Derived : public Base
{
};



int main()
{
    Derived d;
    std::cout<<"End of program";
    return 0;
}

So far so good. Everything works as expected.

However, if I split the classes into their headers and sources as follows.

Base.hpp

// Base.hpp
#pragma once
class Base
{
protected:
    double data;

public:
    Base(double data);
};

Base.cpp

// Base.cpp
#include "Base.hpp"

Base::Base(double data = 10) : data{data} {}

Derived.hpp

// Derived.hpp
#pragma once
#include "Base.hpp"

class Derived : public Base
{
};

Derived.cpp

// Derived.cpp
#include "Derived.hpp"

separate.cpp

// separate.cpp
#include "Derived.hpp"
#include <iostream>

int main(){
    Derived d;
    std::cout<<"End of program";
    return 0;
}

I got a lot of build errors as follows.

> Executing task: C/C++: g++.exe build active file <

Starting build...
"C:mingw32bing++.exe" -g *.cpp -o separate.exe -I F:StackExchangeProgrammingVSCode-Template/cpp
separate.cpp: In function 'int main()':
separate.cpp:5:13: error: use of deleted function 'Derived::Derived()'
     Derived d;
             ^
In file included from separate.cpp:1:
Derived.hpp:4:7: note: 'Derived::Derived()' is implicitly deleted because the default definition would be ill-formed:
 class Derived : public Base
       ^~~~~~~
Derived.hpp:4:7: error: no matching function for call to 'Base::Base()'
In file included from Derived.hpp:2,
                 from separate.cpp:1:
Base.hpp:8:5: note: candidate: 'Base::Base(double)'
     Base(double data);
     ^~~~
Base.hpp:8:5: note:   candidate expects 1 argument, 0 provided
Base.hpp:2:7: note: candidate: 'constexpr Base::Base(const Base&)'
 class Base
       ^~~~
Base.hpp:2:7: note:   candidate expects 1 argument, 0 provided
Base.hpp:2:7: note: candidate: 'constexpr Base::Base(Base&&)'
Base.hpp:2:7: note:   candidate expects 1 argument, 0 provided

Build finished with error(s).
The terminal process terminated with exit code: -1.

Questions

Could you tell me why this issue happened and how to fix it?

Answer

The default argument belongs in the declaration (in the header), not in the definition (in the .cpp file).