- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
anisha@linux-dopx:~/Desktop/notes/pomodoro> ls
timer.cpp
anisha@linux-dopx:~/Desktop/notes/pomodoro> qmake -project
anisha@linux-dopx:~/Desktop/notes/pomodoro> qmake
anisha@linux-dopx:~/Desktop/notes/pomodoro> make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../qtsdk-2010.05/qt/mkspecs/linux-g++-64 -I. -I../../../qtsdk-2010.05/qt/include/QtCore -I../../../qtsdk-2010.05/qt/include/QtGui -I../../../qtsdk-2010.05/qt/include -I. -I. -o timer.o timer.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/anisha/qtsdk-2010.05/qt/lib -o pomodoro timer.o -L/home/anisha/qtsdk-2010.05/qt/lib -lQtGui -L/home/anisha/qtsdk-2010.05/qt/lib -L/usr/X11R6/lib64 -lQtCore -lpthread
timer.o: In function `DigitalClock::DigitalClock(QWidget*)':
timer.cpp:(.text+0x151): undefined reference to `vtable for DigitalClock'
timer.cpp:(.text+0x159): undefined reference to `vtable for DigitalClock'
timer.cpp:(.text+0x1bc): undefined reference to `DigitalClock::staticMetaObject'
timer.o: In function `main':
timer.cpp:(.text+0x2c0): undefined reference to `vtable for DigitalClock'
timer.cpp:(.text+0x2c9): undefined reference to `vtable for DigitalClock'
timer.cpp:(.text+0x30f): undefined reference to `vtable for DigitalClock'
timer.cpp:(.text+0x318): undefined reference to `vtable for DigitalClock'
collect2: ld returned 1 exit status
make: *** [pomodoro] Error 1
我的番茄钟:
######################################################################
# Automatically generated by qmake (2.01a) Tue Feb 14 10:32:09 2012
######################################################################
TEMPLATE = app
TARGET = timer
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += timer.cpp
我的定时器.cpp:
#include <QLCDNumber>
#include <QtGui>
#include <QApplication>
class DigitalClock : public QLCDNumber
{
Q_OBJECT
public:
DigitalClock (QWidget *parent = 0);
private slots:
void showTime();
};
DigitalClock :: DigitalClock (QWidget *parent) : QLCDNumber (parent)
{
setSegmentStyle(Filled);
QTimer *timer = new QTimer(this);
connect (timer, SIGNAL(timeout()), this, SLOT(showTime()));
timer->start (1000);
showTime();
setWindowTitle (tr ("Digital Clock"));
resize (150, 60);
}
void DigitalClock :: showTime()
{
QTime time = QTime::currentTime();
QString text = time.toString("hh:mm");
if ((time.second() % 2) == 0)
text[2] = ' ';
display(text);
}
int main (int argc, char *argv[])
{
QApplication app(argc, argv);
DigitalClock clock;
clock.show();
return app.exec();
}
最佳答案
放
class DigitalClock : public QLCDNumber
{
Q_OBJECT
public:
DigitalClock (QWidget *parent = 0);
private slots:
void showTime();
};
在单独的头文件中并将其包含到 cpp 中。不要忘记像这样将头文件名放在项目文件中
标题 +=\ 数字时钟.h
宏 Q_OBJECT
在一个文件中不起作用。希望对您有所帮助。
关于c++ - 对 `vtable for DigitalClock' 的 undefined reference - 对 `DigitalClock::staticMetaObject' 的 undefined reference - Qt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9272047/
我对 virtual inheritance 很感兴趣这件事给我带来了神秘感。让我们以 virtual inheritance 为例。 : struct Base { virtual void
虽然手头的问题已解决,但让我有点困惑的是什么数据用于构造类的虚表以及虚表的布局存储在哪里。如果有人可以提供澄清或指出一些可能满足我好奇心的信息,我将不胜感激。 背景 两个独立的 VC6.0 项目:一个
关于我的环境的信息 Mac OS 大苏尔:11.4 VS for Mac:8.10.6(内部版本 10) Xamarin.Android:11.3.0.4 SDK 工具版本:26.1.1 SDK平台工
根据我的理解,VTable 是调用最派生版本的函数所必需的。它将包含有关函数的最派生版本的条目......我的疑问是为什么我们需要为基类提供一个 VTable。因为使用基对象进行调用总是需要调用基类函
我读了这篇文章: https://shaharmike.com/cpp/vtable-part2/ 我不明白为什么在 vtable 中(在文章末尾)我们有这个指针: 0x400918 0x400820
#include #include using namespace std; class Foo { public: virtual void f1() { cou
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 9 年前。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。更详细地描述您的问题或inclu
class Base { public: virtual void function1() {}; virtual void function2() {}; }; class D1:
Variant-like 类型通常通过模拟 Vtables 来实现,参见示例 https://www.youtube.com/watch?v=uii2AfiMA0o 现在,作为替代方案,我们可以简单地
假设我有一个继承自 B 类和 C 类的 A 类(多重继承)。A 类有多少 vtable 成员?单继承是什么情况? 此外,假设: Class A : Public B {} 和: B* test = n
我知道这里有很多关于 vtables 的问题,但我还是有点困惑。 只有当我们有一个指向基类的指针来解析要调用派生类的哪个虚函数时,才使用 vtables 吗? 在我下面的示例中,在第一种情况下,是否在
我有一些关于虚拟析构函数和 vtable 的具体问题。 假设我有以下代码: class Base { public: virtual ~Base(); }; class Child : pub
这个问题在这里已经有了答案: What is a vtable in C++ [duplicate] (3 个答案) Why do we need a virtual table? (5 个答案)
如何在位置无关代码中实现虚函数? 我知道如果我的类有虚函数,编译器通常会为它生成一个 vtable,其中包含所有虚函数的地址,并在我的类的每个对象中存储一个指向 vtable 的指针。 现在,如果我的
网上有很多关于虚表的资源。他们通常对他们有相同的陈述: "只要类本身包含虚函数或重写父类的虚函数,编译器就会为该类构建一个 vtable。这意味着并非所有类都有编译器为它们创建的 vtable。 vt
我对 vtables 的理解是,如果我有一个带有虚函数 speak() 的类 Cat,它有子类 Lion 和 HouseCat,则有一个 vtable 将 speak() 映射到每个子类的正确实现。于
vtable 包含指向那个类的虚函数的指针。它是否也包含指向非虚函数的指针? 谢谢! 最佳答案 这是一个实现细节,但不是。如果一个实现将指向非虚函数的指针放入虚表中,它就不能使用这些指针进行函数调用,
我们有没有virtual table对于 abstract class ? 最佳答案 首先,vtables 的使用是实现定义的,而不是标准强制要求的。 对于使用 vtable 的实现,答案是:是的,通
你能解释一下编译器是否为一个有虚函数的类生成了 vtable 并且没有使用那个类(对象不是以任何形式创建的)。比如说, class A { public:
我对 C++ 和虚拟继承感到好奇 - 特别是解决 bass 类和子类之间的 vtable 冲突的方式。我不会假装理解它们如何工作的细节,但到目前为止我所看到的是它们是由于该分辨率而使用虚函数造成的一个
我是一名优秀的程序员,十分优秀!