'How to get around calling base class constructor from derived class with the same arguments?

I want to use a base object that defines an "interface" and then have derived objects implement it. Every object is initialized with its name which is always the same process: Writing to a member "name_" with parameter passed to the constructor. I want to have derived objects behave exactly the same way as the base object in that regard, so every derived object should write to its name varialbe. However, the problem is that I would need to define an extra constructor in every derived object that writes to the name variable which is cumbersome. The following example does not compile because of this reason. Is there any way around this or is inheritance even the right approach (please feel free to suggest otherwise)?

Non-compiling code (shows what I want to do):

#include <iostream>

class A {
    const std::string name_;
    public:
        A(const std::string name) : name_(name) { std::cout << "creation of object " << name_ << "; this name = " << this->name_ << '\n'; }
};

class B : public A {
    // const std::string name_; -- we do not even need this because "name_" also exists for object B.

    // C++ misses its constructor here :') - I don't
};

int main()
{
    A obj_a{ "A" };

    B obj_b{ "B" };
}

Associated error(s):

source>:20:18: error: no matching function for call to 'B::B(<brace-enclosed initializer list>)'
   20 |     B obj_b{ "B" };
      |                  ^
<source>:12:7: note: candidate: 'B::B(const B&)'
   12 | class B : public A {
      |       ^
<source>:12:7: note:   no known conversion for argument 1 from 'const char [2]' to 'const B&'
<source>:12:7: note: candidate: 'B::B(B&&)'
<source>:12:7: note:   no known conversion for argument 1 from 'const char [2]' to 'B&&'
ASM generation compiler returned: 1
<source>: In function 'int main()':
<source>:20:18: error: no matching function for call to 'B::B(<brace-enclosed initializer list>)'
   20 |     B obj_b{ "B" };
      |                  ^
<source>:12:7: note: candidate: 'B::B(const B&)'
   12 | class B : public A {
      |       ^
<source>:12:7: note:   no known conversion for argument 1 from 'const char [2]' to 'const B&'
<source>:12:7: note: candidate: 'B::B(B&&)'
<source>:12:7: note:   no known conversion for argument 1 from 'const char [2]' to 'B&&'


Solution 1:[1]

Even add explicitly B constructor

class B : public A
{
public:
    B(const std::string& s) : A(s) {}
};

or "use" the base's ones

class B : public A
{
public:
   using A::A;
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jarod42