I am trying to learn how sensitive the vtable of a class is in C++ and, for that, I need to know whether recompilation of the entire class hierarchy is necessary for the 3 change-scenarios I list below. First, here is my class hierarchy:
class A {
public:
virtual void method1() = 0;
virtual void method2() = 0;
};
class B : public A {
public:
virtual void method1() {};
virtual void method2() {};
};
class C : public A {
public:
virtual void method1() {};
virtual void method2() {};
};
Here are my scenarios:
-
A non-virtual method is added to the base class A:
void method3() {};
-
A virtual method with a body is added to the base class A:
virtual void method3() {};
-
A purely virtual method is added to the base class A:
virtual void method3() = 0;
In scenario-1, no change to the vtable is made. Is it still required for B and C to be recompiled?
In scenario-2, will the vtable be reconstructed for base A, and consequently for B, and C?
I know scenario-3 will force classes B and C to provide implementations for the new method. So, the entire hierarchy must be recompiled.
Aucun commentaire:
Enregistrer un commentaire