#include <iostream>
#include <cstring>

struct test
{
public:
    test(const std::string& str) : name(new char[str.length() + 1])
    {
        strcpy((char*)name, str.c_str());
    }
    // Rule of three
    //   -- Copy ctor
    //   -- Copy assignment operator
    // Rule of five
    //   -- Move ctor
    //   -- Move assignment operator
    ~test() { delete[] name; }
    void printName() { std::cout << name << std::endl; }
private:
    const char* name;
};


int main()
{
    std::string s{"test"};
    test t{s};
    t.printName();
}