Possible Duplicate:
Does an abstact classes have a VTABLE?
Does a vtable gets created for an abstract class that have pure virtual functio开发者_C百科ns and virtual functions ?
class Abstarct {
public:
virtual void f() = 0;
virtual void g() {}
};
Thanks.
I just saw that none of the answers in the other topic clearly answers it.
The answer is: Yes and No.
Since the vtable and vptr is implementation-defined concept and is not mandated by the C++ Standard, so compilers are free to choose any approach as long as it does dynamic dispatching of the virtual
functions (pure or otherwise).
So for the compilers which implement vtable and vptr, the answer is YES (or most likely, YES) and for other compilers which do not implement vtable & vptr and instead implement dynamic dispatching in some other way, the answer is obviously NO.
See this topic:
How can C++ virtual functions be implemented except vtable?
精彩评论