Hi,
I am understanding vtable concept and having some specific question.Can you provide me input.
1. Can we print vtable and its function.
2. Can we determine how many vtable has been created. (Theory yes) but any progrma or command which give some more info.
What do you mean by printing a function?
'how many vtable has been created' ? You mean, how many functions are in it? Or how many classes have such tables? Well, you can't do either.
No./No.
The C++ standard doesn't mention anything about vtables, it's just a popular way to implement virtual functions and related features.
However, when vtables are used, the pointer to the vtable is usually the first thing in the memory layout of an object instance, so you can get the appropriate vtable that way.
Of course, that's non-portable and serves no real purpose anyway.
adding little bit more info...
'how many vatable has been created" : I intend to say when we declare virtual function and
and use in single/multiple/multilevel inheritance than how many vtable are created
a very simple example:
class base
{
public:
virtual void fun();
}
class derived : public base
{
}
In this case we get two virtual table ( as per theory). So can we have some program
or any command in gdb debugger which give me info about vtable creation.
How many vtable has been created?