I know there are so many questions about virtual funcion.And sorry for this question but i really don't understand how code finds correct VTable(not function)
I read here : http://www.parashift.com/c++-faq-lit....html#faq-20.4
ıt says:"The idea is to change each Der object's v-pointer so it points at its class's v-table. (This is not a second v-pointer; it's the same v-pointer that was defined in the base class, Base; remember, the compiler does not repeat step #2 in class Der"
I confused here.
How many are vtables created?
amount of base+derived class.One VTABLE for each.But all of them has one VPTR.IS this right?
So if there is a VTABLE for each class but one VPTR; How can code find the correct function?
I know calling virtual func. means calling an offset.But this offset is in the class's VTABLE.But first it must find one more offset that indicate correct class?
Am i wrong?
For example i have one base class and one virtual funct. and three derived class in a dll.Here when i call to 3. derived class virtual function from base class pointer from my exe.Here first it must find 3. VTABLE and and first offset.Right?
But here we have only one VPTR so haw can it find 3. VTABLE and then offset of the function?
I am looking for your answers