I think u got it wrong. Whenever we use virtual keyword, compiler defers the function call resolution for the runtime. So, at the runtime, it checks what the type of object is(Base or Derived) and then it selects the appropriate vptr and call the function from the corresponding vTable. Ref: Thinking in C++
+Yogendra Hada hi.. you are right about the vptr and vtable, it doesn't check object type at run time, it simply uses something like: obj->vptr->vtable[0]. on the object what it gets. and this happens at compile time. so if you have something like obj->fun1() this will be replaced with obj->vptr->vtable[0] at compile time. At run time only one level of indirection happen and that is, it goes to location 0 and take take address of function and put here and call it with parameters.. (0 is the location where fun1 address is stored) it is little difficult to explain here i will creat different video for that. wait for some time.. and i am not wrong, i just don't wanted to include vptr and vtable question in static and dynamic question bcoz they are different questions. :)
Roopesh is not wrong yog.. He is trying to explain the main subject (static and dynamic binding ).. If you want detailed explanation about vptr, vtable etc, then you need to go through some other video. Because vptr , vtable etc., kind of concepts will take more video length.
I have few questions related to dynamic linking : what is Global offset table , what is procedure linkage table and what is pic (procedure independent code)
Procedure linkage table is an array of addresses left by the compiler in an ELF file to be filled with addresses of the dynamically loaded library functions the ELF depends on during runtime. Compiler while creating the ELF file designates space for this array inside the file and 'tags' it as PLT, and during execution (runtime) when the ELF file is actually loaded inside a memory address space along with other libraries the ELF file depends on, the loader searches for the library functions needed for the ELF to run and populates the PLT with the the runtime address of these functions.
thanks for this video , what about defining the function in Derived class virtual and in base class without? i have tried, and the compiler has shown: Base fun Base fun it hasn't care about the new Derived, although the func. in Derived class is virtual can you pls explain ?
Since you didn't specify virtual in the base class, the compiler will not treat the function as such. The method call will be complete at compile time and no check will be made at run.
Kosis kiyee hongee hum per ab tumko deep nahi laga to sorry, ek salah hai thoda google kero aur bhi padhoo. Kabhi bhi pura gyaan eek jaga se nahi hasil hota hai. 🙂
Thank you, sir! You have cleared up my confusion. Jajakallah Khairan.
I think u got it wrong. Whenever we use virtual keyword, compiler defers the function call resolution for the runtime. So, at the runtime, it checks what the type of object is(Base or Derived) and then it selects the appropriate vptr and call the function from the corresponding vTable. Ref: Thinking in C++
+Yogendra Hada hi..
you are right about the vptr and vtable, it doesn't check object type at run time, it simply uses something like: obj->vptr->vtable[0].
on the object what it gets. and this happens at compile time. so if you have something like obj->fun1() this will be replaced with obj->vptr->vtable[0] at compile time. At run time only one level of indirection happen and that is, it goes to location 0 and take take address of function and put here and call it with parameters..
(0 is the location where fun1 address is stored) it is little difficult to explain here i will creat different video for that.
wait for some time..
and i am not wrong, i just don't wanted to include vptr and vtable question in static and dynamic question bcoz they are different questions. :)
Roopesh is not wrong yog.. He is trying to explain the main subject (static and dynamic binding ).. If you want detailed explanation about vptr, vtable etc, then you need to go through some other video. Because vptr , vtable etc., kind of concepts will take more video length.
I have few questions related to dynamic linking : what is Global offset table , what is procedure linkage table and what is pic (procedure independent code)
Procedure linkage table is an array of addresses left by the compiler in an ELF file to be filled with addresses of the dynamically loaded library functions the ELF depends on during runtime. Compiler while creating the ELF file designates space for this array inside the file and 'tags' it as PLT, and during execution (runtime) when the ELF file is actually loaded inside a memory address space along with other libraries the ELF file depends on, the loader searches for the library functions needed for the ELF to run and populates the PLT with the the runtime address of these functions.
thank you nice an short explanation
Hi; you should notice that you are use pointer; what if call function by value
F(C c){c.func();}
G(C& c){c.func();}
Try it?
Please try to explain the "WHY". "WHAT" is available everywhere. :(
Sure man..
thanks
Thanks
@@CppNuts really helpfull
What is the name of this software in which you are coding
Sublime Test Editor.
Thank you man.
You're welcome!
Pls cover one video on static and dynamic linkage
sorry its external and internal linkage.
good bhai meri ignou ka exam pass kara diya aapne
Areee waah kyaa baat hai.. 👍👍
@@CppNuts thanks bhai
thanks for this video , what about defining the function in Derived class virtual and in base class without?
i have tried, and the compiler has shown:
Base fun
Base fun
it hasn't care about the new Derived, although the func. in Derived class is virtual
can you pls explain ?
Since you didn't specify virtual in the base class, the compiler will not treat the function as such. The method call will be complete at compile time and no check will be made at run.
👌
coool
Really nice video!
Is there an advantage in using pointers?
Thanks Man!!
Reference will also do the job.
Video is not useful for Beginners!
Bhai kidharrr thoda achese smzao deeply
Kosis kiyee hongee hum per ab tumko deep nahi laga to sorry, ek salah hai thoda google kero aur bhi padhoo.
Kabhi bhi pura gyaan eek jaga se nahi hasil hota hai. 🙂
abe smjhana nhi ata to ku video bnate ho
Kyaa samaj nahii ayaa bee 😀😀