Questions tagged [vtable]

A virtual table, or vtable, is a technique used to implement polymorphic functions with dynamic dispatch

In C++ (and other languages) a vtable contains pointers to a polymorphic type's virtual functions, allowing the language runtime to do dynamic dispatch by looking up the relevant entry in an object's vtable. The lookup is generally implemented by accessing the table at a fixed offset determined at compile time.

A object of a polymorphic type contains a pointer to its class' vtable and the vtable contains a pointer to the final overrider of each virtual function (i.e. the implementation of the function in the most-derived type that overrides the function.)

617 questions
0
votes
2 answers

Incorrect vtable layout for class exported by DLL: request for clarification regarding headers and vtable construction

Although the problem at hand is solved, it has me a little confused as to what data is used to construct the vtables for a class and where the layout for the vtable is stored. If anyone can provide clarification or point me towards some information…
acanaday
  • 400
  • 1
  • 11
0
votes
1 answer

GCC: strange unresolved reference on function which doesn't used

#include struct CL1 { virtual void fnc1(); virtual void fnc2(); //not defined anywhere }; void CL1::fnc1(){} int main() {} This gives an undefined reference error on fnc2, however it isn't used anywhere. Why is this happening?…
Denis
  • 2,786
  • 1
  • 14
  • 29
0
votes
1 answer

How to get a complete row data from VTS?

I am using VTS tables for passing data from 1 script to other. Now, I want to get data from all the column for particular row and print that. I tried couple of VTC commands but unfortunately that did not work. Command I tried:- rc =…
0
votes
0 answers

Undefined reference to vtable issues

im having some trouble with compiling a c++ project, keep getting: undefined reference to 'typeinfo for FileModule' FileModule is a base class with some classes inheriting it. FileModule itself is inheriting from a base class called Module,…
Liron
  • 9
  • 1
0
votes
0 answers

C++ multiple inheritance with interface

I have a question concerning multiple inheritance. In my project, I want to add support for dll plugins and need an interface for that reason. In the application, I create objects like players and visual objects and hand them to the dll interface.…
truepaddii
  • 9
  • 1
  • 3
0
votes
1 answer

Variant-like types: Why a vtable?

Variant-like types are often implemented by simulating Vtables, see e.g. https://www.youtube.com/watch?v=uii2AfiMA0o Now, as an alternative, one could simply use a switch statement. Question: Is there any reason for preferring a vtable to a switch…
JohnB
  • 13,315
  • 4
  • 38
  • 65
0
votes
4 answers

suspicions of multithreading race conditions in c++ virtual calls w/ vtable implementation

I have a suspicion that there might be a race condition in a certain C++ multithreading situation involving virtual method calls in a vtable dynamic dispatching implementation (for which a vtable pointer is stored as a hidden member in the object…
user383246
  • 11
  • 1
0
votes
3 answers

Derived class VTable having only base class virtual functions. The derived class virtual functions are missing from derived class's vtable

Here is a very basic example: class Base { public: virtual void sayHi() const {} virtual void sayHello() {} virtual ~Base(){} }; class Derived : public Base { public: virtual void sayHi() {} virtual void sayHello() const…
Abhinav
  • 1,496
  • 3
  • 15
  • 31
0
votes
3 answers

How polymorphism works involving multiple inheritance?

I'm studying topics related to multiple inheritance now. I came up with the following code, and couldn't totally figure out the mechanism behind it: struct root { virtual void vfunction(){ /* root version */ } }; struct mid1:public root { …
0
votes
0 answers

Undefined reference to vtable for WaypointModel

So I'm getting this error message in QTcreator, undefined reference to table for waypointModel. This seems to be a common problem, and I've tried the solutions suggested on this site. Everything from running Qmake again, rebuilding, cleaning. Going…
Hawken
  • 11
  • 2
0
votes
1 answer

Multiple Vtables ad VPointers in C++

I have been reading on vtables and pointers, but there is a few questions I still have. For example: #include using namespace std; class A { public: virtual void PrintA()=0; //1 vtable and 1 vpointer }; class B { public: virtual…
Mr. Bombastic
  • 11
  • 1
  • 2
0
votes
3 answers

understanding of multiple inheritance for c++

I'm reading multiple inheritance for c++ An Example in the paper:(page 377) class A {virtual void f();}; class B {virtual void f(); virtual void g();}; class C: A, B {void f();}; A* pa = new C; B* pb = new C; C* pc = new…
Fihop
  • 3,127
  • 9
  • 42
  • 65
0
votes
0 answers

change interface from IUnknown to IDispatch

I have a COM class which is accessible only via vtable. It is already distributed to clients. I am planning to allow script access as well, by introducing IDispatch. In my local tests, it shows client code will not change, but they will require code…
Logan
  • 184
  • 10
0
votes
1 answer

Undefined reference to vtable even when virtual methods have been implemented

I am trying to compile the latest version of QEmacs (a tiny version of Emacs): https://github.com/dmacvicar/qemacs Everything is OK, I have the needed libraries, including Qt, but in the linking phase, the linker gives errors undefined reference to…
Ho1
  • 1,239
  • 1
  • 11
  • 29
0
votes
4 answers

Getting list of all existing vtables

In my application I have quite some void-pointers (this is because of historical reasons, application was originally written in pure C). In one of my modules I know that the void-pointers points to instances of classes that could inherit from a…
Patrick
  • 23,217
  • 12
  • 67
  • 130