I read that an abstract class can still have a table. But I'm confused on how many entries it would have in its vtable. For example, if my abstract class was:
class Circle(){
virtual void draw() = 0;
}
then how many entries would be in its vtable? Also, am I correct in saying that this abstract class has 1 entry in its vtable? Thanks for any help.
class Circle(){
virtual double a{ return 0.0; }
virtual void draw() = 0;
}
Every virtual function can be overridden. The compiler has to build in some mechanism to dynamically dispatch calls to each virtual function so that the code calls the right overriding version, which depends on the actual type of the object. That mechanism is typically a vtable, and there has to be one entry for each virtual function. So the first example would have one entry, and the second would have two. Note that marking a function as pure virtual does not affect this; it still has to be dynamically dispatched.