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

Qt undefined reference to `vtable for Msnger'

I get this error /.../mainwindow.o:-1: In function `MainWindow::MainWindow(QWidget*)': /.../mainwindow.cpp:-1: Chyba:undefined reference to `vtable for Msnger' and i dont understand why. Only problems i found causing this message are declaration…
Matthew.J
  • 65
  • 1
  • 9
0
votes
1 answer

error with virtual functions (vtable?)

Well I am getting an error since I added virtual functions that I have no idea about it. Do you? There are three errors in total: window.h:22: undefined reference to `vtable for bwindow' window.cpp:16: undefined reference to `vtable for…
newtonis
  • 47
  • 1
  • 8
0
votes
1 answer

undefined reference for vtable when creating tree nodes

I am a student tacking a data structures class and running into some trouble for my last assignment. The purpose is to create a binary expression tree using some predefined classes of nodes that our professor has supplied. The file we are provided…
0
votes
4 answers

Object memory layout in C++ and how its structure depends on most platforms

I have two classes in C++: class Base { int baseField; public: Base(); ~Base(); T BaseMethod(); virtual SomeMethod()=0; }; class Derived : public Base { int derivedField; public: Derived() ~Derived(); T DerivedMethod(); …
CppMonster
  • 1,216
  • 4
  • 18
  • 35
0
votes
0 answers

Missing Vtable when linking .o files

I am writing a simple server program using ICE by ZeroC. When I try to link the .o files it gave me the following error message: $ c++ -o server UserMap.o Server.o -L/Library/Developer/Ice-3.5.0/lib -lIce -lIceUtil Undefined symbols for architecture…
Tengyu Liu
  • 1,223
  • 2
  • 15
  • 36
0
votes
7 answers

Virtual tables are undefined

I wrote some code but I am unable to compile it: #include #include using namespace std; class Visitor; class Land { public: virtual void accept(const Visitor *v); }; class England : public Land { public: void…
Martin
  • 1,473
  • 2
  • 12
  • 20
0
votes
2 answers

virtual functions in static libraries

When I have an abstract base class foo, defined in libX.a class foo { virtual void bar() = 0; }; ... and a derived class foo_impl, defined in libY.a class foo_impl : public foo { void bar() { /* do something */ } }; ... and use both…
idefixs
  • 712
  • 1
  • 4
  • 14
0
votes
2 answers

"Undefined reference to vtable in Line "in constructor

I'm getting the error message stated in the title. I'm trying to construct a class Line which has inherited the class Shape. I get an error in the Shape(color) {} execution in the line constructor. Header files (Shape and Line in one, Color in…
user1784297
  • 103
  • 12
0
votes
1 answer

Undefined reference errors in Qt application

I have a library and example application, driven by CMake. So, there is a class, which I use in library: sourceeditor.h #ifndef SOURCEEDITOR_H #define SOURCEEDITOR_H #include #include "novile_export.h" namespace Novile { class…
0
votes
1 answer

"vtable" in the dexdump result

I'm doing some research on dexdump. Now, there is a question that confuses me. when you look at the dexdump result, you will find "vtable" in the code like this: 000854: fa20 a900 4300 |0000: +invoke-super-quick {v3, v4},…
Felix
  • 1
0
votes
2 answers

Where are virtual tables really stored, and why can't we modify them?

I know the vtables are stored as read-only in memory to prevent modifications. Which section is exactly storing vtables? Another question, according to read-only privileges that vtables have, how they got modified in exploit writing process?
n1kita
  • 263
  • 1
  • 5
  • 15
0
votes
2 answers

why is the base function called instead?

In the following code: #include using namespace std; class A { public: A() { cout << " A constructor \n"; sum(2,4); } virtual int sum(int a, int b){ cout << "Base sum \n"; return a + b; …
brainydexter
  • 19,826
  • 28
  • 77
  • 115
0
votes
3 answers

can't fix undefined reference to vtable

I've been searching for a while and have found a lot of threads/pages that involve the problem I have, but I am not able to find An explanation of why this error occurs A working solution for my specific case The following is Scanner.h: class…
Niklas R
  • 16,299
  • 28
  • 108
  • 203
0
votes
1 answer

why both constructor of Base class and Drive class run when initialize instance of Drive class

#include using namespace std; class Base { public: Base() { cout << "In Base" << endl; cout << "Virtual Pointer = " << (int*)this << endl; cout << "Address of Vtable = " <<…
cao_bang
  • 199
  • 1
  • 4
  • 17
0
votes
3 answers

C++: prototype of a virtual pointer

I am not sure if this is documented anywhere. We all know in case of virtual functions, each class holds a vptr which pointer to an array of function pointers called the virtual table. I want to know what is the prototype of the vptr. For ex, if a…
rahul
  • 6,447
  • 3
  • 31
  • 42