Linker 错误42:符号未定义

Linker 错误42:符号未定义,linker,d,Linker,D,我曾试图用D编写一个小程序,但我不断收到链接错误(尽管我不使用外部库)。确切的错误消息是error 42:Symbol Undefined\u D4main4mainfayazv6clientmfzc6client6client6client。我的代码是 interface Component { public: string GetIdentifier(); void Activate(JSONValue data); } class SomeComponent : Comp

我曾试图用D编写一个小程序,但我不断收到链接错误(尽管我不使用外部库)。确切的错误消息是
error 42:Symbol Undefined\u D4main4mainfayazv6clientmfzc6client6client6client
。我的代码是

interface Component
{
public:
    string GetIdentifier();
    void Activate(JSONValue data);
}

class SomeComponent : Component
{
public:
    string GetIdentifier()
    {
        return "SomeComponent";
    }
    void Activate(JSONValue data)
    {
        writeln("Something");
    }
}

class Client
{
public:
    Component[] components;
    void register(Component c)
    {
        components ~= c;
        writeln(c.GetIdentifier());
    }
}

void main(string[] args)
{
    Client client();
    SomeComponent d;
    client.register(d);
}
在D中,这将声明一个不带参数的函数,该函数返回一个
客户机
实例

这将尝试调用声明的函数。但是,由于没有函数体,程序将编译,但链接失败,因为链接器将无法找到函数体

你可能是说:

auto client = new Client();
在D中,这将声明一个不带参数的函数,该函数返回一个
客户机
实例

这将尝试调用声明的函数。但是,由于没有函数体,程序将编译,但链接失败,因为链接器将无法找到函数体

你可能是说:

auto client = new Client();
auto client = new Client();