vtable

Inversion of generated vtable functions order for functions with the same name

本小妞迷上赌 提交于 2021-02-11 13:56:38
问题 If, using Visual Studio 2019, I compile this C++ code with two virtual methods having the same name but different arguments: struct MyStruct { virtual void foo(float) = 0; virtual void foo(int) = 0; }; class MyClass : public MyStruct { public: void foo(float) {} void foo(int) {} }; static MyClass c; The order of methods in the generated class' vtable is inverted. Here is the output in https://godbolt.org const MyClass::`vftable' DQ FLAT:const MyClass::`RTTI Complete Object Locator' ; MyClass:

How does the virtual inheritance table work in g++?

北战南征 提交于 2021-01-28 08:25:38
问题 I'm trying to get a better understanding how virtual inheritance works in practice (that is, not according to the standard, but in an actual implementation like g++ ). The actual question is at the bottom, in bold face. So, I built myself a inheritance graph, which has among other things, these simple types: struct A { unsigned a; unsigned long long u; A() : a(0xAAAAAAAA), u(0x1111111111111111ull) {} virtual ~A() {} }; struct B : virtual A { unsigned b; B() : b(0xBBBBBBBB) { a = 0xABABABAB; }

Nothing helped to solve “Undefined reference to vtable” in Qt

送分小仙女□ 提交于 2021-01-28 02:57:25
问题 I can't build this with error "undefined reference to vtable for CustomUndoStack" Here's the code: class CustomUndoStack : public QObject { Q_OBJECT public: }; int main(int argc, char *argv[]) { QCoreApplication qCoreApplication(argc, argv); CustomUndoStack uStack; return qCoreApplication.exec(); } Here's .pro file: QT += widgets CONFIG += c++14 console CONFIG -= app_bundle DEFINES += QT_DEPRECATED_WARNINGS SOURCES += main.cpp I've deleted manually the build directory, I've tried "Clean All"

Virtual Table layout in memory?

旧城冷巷雨未停 提交于 2020-05-25 04:56:11
问题 how are virtual tables stored in memory? their layout? e.g. class A{ public: virtual void doSomeWork(); }; class B : public A{ public: virtual void doSomeWork(); }; How will be the layout of virtual tables of class A and class B in memory? 回答1: As others have said, this is compiler dependant, and not something that you ever really need to think about in day-to-day use of C++. However, if you are simply curious about the issue, you should read Stan Lippman's book Inside the C++ Object Model.

Virtual Table layout in memory?

核能气质少年 提交于 2020-05-25 04:53:04
问题 how are virtual tables stored in memory? their layout? e.g. class A{ public: virtual void doSomeWork(); }; class B : public A{ public: virtual void doSomeWork(); }; How will be the layout of virtual tables of class A and class B in memory? 回答1: As others have said, this is compiler dependant, and not something that you ever really need to think about in day-to-day use of C++. However, if you are simply curious about the issue, you should read Stan Lippman's book Inside the C++ Object Model.

Wrong vtable generated by C++ compiler (for COM object)

让人想犯罪 __ 提交于 2020-05-15 08:01:12
问题 I have this C++ code that defines a IMyInterface COM interface. The only subtlety is it defines two methods with different parameters but same name: struct __declspec(uuid("bd8a0cfc-312e-4871-8f82-07adab05c6d0")) __declspec(novtable) IMyInterface : public IUnknown { virtual HRESULT __stdcall SetValue(float value) = 0; virtual HRESULT __stdcall SetValue(int value) = 0; }; Here is a simple implementation: class MyClass : public IMyInterface { public: // poor man's COM object impl HRESULT

Wrong vtable generated by C++ compiler (for COM object)

柔情痞子 提交于 2020-05-15 08:01:05
问题 I have this C++ code that defines a IMyInterface COM interface. The only subtlety is it defines two methods with different parameters but same name: struct __declspec(uuid("bd8a0cfc-312e-4871-8f82-07adab05c6d0")) __declspec(novtable) IMyInterface : public IUnknown { virtual HRESULT __stdcall SetValue(float value) = 0; virtual HRESULT __stdcall SetValue(int value) = 0; }; Here is a simple implementation: class MyClass : public IMyInterface { public: // poor man's COM object impl HRESULT

Undefined reference to vtable… Q_OBJECT macro [duplicate]

不打扰是莪最后的温柔 提交于 2020-02-16 06:23:26
问题 This question already has answers here : Qt Linker Error: “undefined reference to vtable” [duplicate] (9 answers) Closed 6 years ago . When I uncomment the Q_OBJECT macro that I need for signal-slot I get a undefined reference to vtable for MyApp error, but without the macro it compiles perfectly but I can't use signals and slots without it. I think I may be doing something stupid wrong, but please try helping because I realy can't find the problem. O and I know my code is untidy and am

Undefined reference to vtable… Q_OBJECT macro [duplicate]

拟墨画扇 提交于 2020-02-16 06:22:14
问题 This question already has answers here : Qt Linker Error: “undefined reference to vtable” [duplicate] (9 answers) Closed 6 years ago . When I uncomment the Q_OBJECT macro that I need for signal-slot I get a undefined reference to vtable for MyApp error, but without the macro it compiles perfectly but I can't use signals and slots without it. I think I may be doing something stupid wrong, but please try helping because I realy can't find the problem. O and I know my code is untidy and am