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
-1
votes
1 answer

undefined reference to vtable; virtual function issue

Suppose I override a virtual function in a child class with a declaration, and do not give a definition for the method. For example: class Base { virtual void f() = 0; } class Derived : public Base { void f(); } (where I haven't given the…
-1
votes
2 answers

compilation error regarding name hiding ,override and virtual table

I was playing c++ rule. I hit an error but i can't explain it. please help to explain why the compilation error happen. BTW, I am not interesting at fixing the problem. Thanks Q1 why the name hiding doesnt work in the case? for example, if we…
cppython
  • 1,209
  • 3
  • 20
  • 30
-1
votes
2 answers

Allocating an object for abstact class type if not implemented and missing vtable error if declared and defined

I have to inherit an abstract base class which has 5 virtual functions. If i dont implement those 5 functions I get "Allocating an object for abstact class type if not implemented". When i declare and implement in derived class I get "Undefined…
Raj iOS
  • 1,047
  • 1
  • 9
  • 20
-2
votes
3 answers

how does the 'this' pointer work in inheritance in c++?

questions: in the code below, the 'this' pointer points to different things in base and derived classes, even though it technically contains the same address. why is that. what is happening when the 'this' pointer is used with inheritance. (any…
-2
votes
1 answer

how to change the vtable symbol to a global symbol?

I have compiled a so file(libarfoundation_core.so) which has a base class ARSRGpuFilter, and a other so file which need dependency the compiled so file could not compiled because " undefined reference to `vtable for…
zhang hang
  • 27
  • 5
-2
votes
1 answer

Undefined reference to vtable when functions are defined in VS Code

I've seen a lot of questions about this, but can't seem to see what I'm missing. I am fairly new at C++. I am using Visual Studio Code with G++ and MINGW32 10.3.0. When I attempt to run test.cpp (below) I receive two errors: ...test.cpp:7: undefined…
-2
votes
1 answer

undefined reference to 'vtable for'

So this is part of a bigger project. I have 3 different files. The first one is a class from a previous project that is just being used as a type (visitor.h) so I won't include it as I know it works. Then I have written an abstract class and another…
-2
votes
2 answers

How exactly c++ vtable works? (with example in the q.)

lets take an c++ example: class A { public: A() { cout << "hey" << endl; } ~A() { cout << "by" << endl; } }; class B : public A { public: B() {} virtual ~B() { cout << "from b" << endl; } }; int main() { A * a = new…
joy
  • 1
  • 1
-2
votes
1 answer

Hack the virtual table of a C++ object without a reference

I know this question was asked here before but it is not exactly what I need, and as much as I try to manipulate the answers from this thread I cannot get the result I'm looking for. So basically what I want to do is manipulate the virtual table in…
Lior Naar
  • 85
  • 1
  • 9
-2
votes
1 answer

Undefined reference to "vtable"

Here is my program. It has a base class, Point, a class colored_point inherited from Point, and a class dim3_point inherited from colored_point. In the class Point there is a virtual function Initializer() and there is one in other classes as well.…
Dang Manh Truong
  • 795
  • 2
  • 10
  • 35
-2
votes
1 answer

Undefined reference to vtable in Qt Widgets [Codeblocks]

I'm getting the error "reference undefined to "vtable for FlussoAudio" in this code, i can't find a reason for this error. FlussoAudio.cpp #include #include #include "FlussoAudio.h" FlussoAudio::FlussoAudio(QWidget *parent) :…
Delayer
  • 409
  • 1
  • 5
  • 17
-3
votes
2 answers

You Only Pay For What You Use vs. Inheritance

One line touted in discussions about what good C++ looks like is "you only pay for what you use". I have heard this used as justification to not use inheritance/polymorphism constructs and the idea of coding to an interface, because these constructs…
tjcertified
  • 694
  • 7
  • 18
-3
votes
1 answer

MSVC 2012 generates different vtable pointer offsets for different files

Let's say I've got in X64 release configuration It's a an obfuscated code snippet... // Hdr1.h // Dozen of includes class Cls1 { public: Cls1(); virtual void bar(); // ... protected: // about 7 fields where some of them are of complex…
Zorgiev
  • 794
  • 1
  • 7
  • 19
-3
votes
1 answer

Despite no Virtual Functions, Undefined reference to Vtable

I have a base class and a derived class, angelic_wing(the derived one), and angelic_event(the base one). When I compile, I get the following two errors: /tmp/ccG6KlZF.o: In function `angelic_wing::angelic_wing()': angelicwing.cpp:(.text+0x20):…
Druid
  • 133
  • 3
  • 12
-4
votes
2 answers

Concept of vptr and vtable in C++

Why only default constructor only able to create vptr(Virtual Table Pointer) and vtable(Virtual Table)? Why parameter constructor not able to
1 2 3
41
42