Classes part 18 - Understanding the vtable (Popular interview question) | Modern Cpp Series Ep. 54

preview_player
Показать описание

►Lesson Description: In this lesson I show you what exactly the vtable is in C++. The vtable is the data structure which holds information about which member functions to call for an instance of class when the presence of 'virtual' exists in inheritance. Understanding a little bit about this data structure, will also give you some intuition about a small performance cost (i.e. storage for the pointer, and following a pointer to call a function) about virtual functions as well.

►Please like and subscribe to help the channel!
Рекомендации по теме
Комментарии
Автор

Great video. Very neatly explained as always. Thank you.

dhanushs
Автор

Thank you i waited for this topic for long its crystal clear now.

jugalshah
Автор

kudos for your hardwork. But it's difficult to understand, can you explain again with good diagrams?

tejasbachhav
Автор

What's the link with the multiple inheritance vtables mentioned at the end?

heretoinfinity
Автор

If I don't override a base function, is vtable still created for my derived class? Or only the pointer is inherited and points straight to the base vtable? For instance:

class Base {
public:
virtual void swim() {}
}

class Derived: public Base {}

Derived derived;

grenadier
Автор

virtual pointer and virtual table are part of class. So what is the type of virtual pointer and virtual table?

kunalkumar-icdc
Автор

why destuctors have to be virtual and constructors can't be virtual, I was asked this once in an interviews, still not sure I have realize an answer.

antonfernando
Автор

Is that vim please? I need to settle smth

zizicz
Автор

Hi, I am strugling with this vtable error. Please help
Below is the arduino code for ePaper display.

#include <GxEPD.h>
#include //2.13" E-paper Module (White/Red/Black)
#include <Fonts/FreeMonoBold18pt7b.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
GxIO_Class io(SPI, SS, 17, 16);
GxEPD_Class display(io, 16, 4);

void setup() {
}
void loop() {
}

Here is the error below
undefined reference to `vtable for GxIO'

collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

mouseminer
Автор

Dude, use a slide show or something rather than writing.

snapman