Trying to make a custom string class and I keep getting C2440 and a E0415 errors

  c++

I’m self teaching from a book. I’m using this example from a book to work with a custom string class and and I keep getting

Error (active) E0415 no suitable constructor exists to convert from "const char [15]" to "Stringz"
and
Error C2440 ‘initializing’: cannot convert from ‘const char [15]’ to ‘Stringz’

please help me understand what’s wrong.
I’ve got a pointer to char in the private field. the constructor initializes with whatever was sent from main as an argument, the length of the argument is taken and used to dynamically allocate the appropriate amount of memory, and finally the address is put in *str in the private field. I tried putting. Any input is appreciated

    #include <iostream>
using namespace std;

class Stringz
{
private:
    char* str;
public:

    Stringz(char* s)
    {
        int length = strlen(s);
        str = new char[length + 1];
        strcpy(str, s);
    }
    ~Stringz()
    {
        cout << "deleting.." << endl;
        delete[]str;
    }

    void display()
    {
        cout << str << endl;
    }
};

int main()
{
    
    Stringz s1 = "made a string ";

    s1.display();
    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT