请教大神们,这段代码哪里错了?

运行时在main函数给x1赋值时报错,说是没有与参数列表匹配的构造函数X::X实例

#include<iostream>
#include<string>
using namespace std;

class X {
private:
    char *s;
public:
    X(char *b) {
        s = new char[sizeof(b) + 1];
        strcpy(s, b);
    }
    ~X() { delete s; }
    void display() { cout << "s=" << s << endl; }
};
void main() {
    X x1("ok");
    X x2(x1);
    X x3 = x1;
    x2.display();
    x3.display();
    system("pause");
}

x2传的不是字符指针

你试试换成g++/gcc编译应该是可以的,如下图:
不过有个警告,就是你传入字符串,但是函数声明的时候是char型指针,这个从字符串常量转化为char形指针已经废除了
图片说明