gpt4 book ai didi

c++ - QT中的Q_OBJECT(对vtable xxx的 undefined reference )

转载 作者:行者123 更新时间:2023-11-28 00:05:24 25 4
gpt4 key购买 nike

<分区>

我写了一个简单的测试如下:

#include <QCoreApplication>
#include <QObject>

class Foo : public QObject
{
Q_OBJECT
};

class foo1
{
};

int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
Foo f;
return a.exec();
}

这给了我一个错误:

error: undefined reference to `vtable for Foo':

但是,当我将 Foo f 更改为 Foo f() 时,它没有任何错误地符合要求。
所以我的问题是 ff() 有什么区别?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com