Hi, is it possible to know if a class has virtual function definition from the object of it? given that I do not have access to the source code of it...
I think he means, for instance, in a plugin system. What if that plugin didn't implement a function?
If that is true, it depends. You'll have to explain more about what you're doing.
No, there is no compilation error in the class definition. question is as follows -
class A
{
public:
virtual void foo(){};
};
int main()
{
A a;
// how can i check object "a" has "a virtual function" ?
}
when a class has any virtual function, it would have a vtable associated with it. can i check in main if that vtable exists? if so, what is the size of that vtable? mere existence of vtable would indicated existaene of a virtual function in a class definition.
A class containing at least one virtual function should have its destructor declared virtual as well. Boost provides the has_virtual_destructor<> type trait