Theoretically, the vtable conatins pointer to each virtual function of the
class.
Each object of this class contains a pointer called vptr to this virtual
table.
But will the space occupied by the v-table be part of the memory occupied by
the class?
If the memory needed by v-table is part of class, then the class memory size
will be increased by 4n, where n is the number of virtual functions in the
class and the machine is 32 bit.

Please correct me if I am wrong.
Would appreciate if someone clarifies if the vtable is created in class
memory or in any other memory space.

-- 
Thanks,
Amit Kumar Basak


On Tue, Mar 29, 2011 at 1:47 AM, hammett <hamm...@gmail.com> wrote:

> Off the top of my head, virtual functions are implemented through
> v-tables http://en.wikipedia.org/wiki/Virtual_table
> The size should be the size of a native pointer (4 bytes in 32
> machines) but I could be wrong.
>
>
> On Mon, Mar 28, 2011 at 11:37 AM, himanshu kansal
> <himanshukansal...@gmail.com> wrote:
> > can u gv any link for reference...???
> >
> > On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR <
> deok...@gmail.com>
> > wrote:
> >>
> >> there is vtable known as virtual table which contains addresses of
> virtual
> >> functions .
> >> And there is vptr a pointer that points to vtable of that class space
> >> occupied by class having virtual function wil be equal to space occupied
> by
> >> a pointer * number of virtual functions ..
> >> I think this if there is any correction please let me  know...
> >>
> >> On Sat, Mar 26, 2011 at 12:00 PM, himanshu kansal
> >> <himanshukansal...@gmail.com> wrote:
> >>>
> >>> wht is the space occupied by a class in c++ whn it contains a virtual
> >>> fn.....
> >>> How are the virtual fn implemented internally by c++.......
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to algogeeks@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> algogeeks+unsubscr...@googlegroups.com.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>
> >>
> >>
> >> --
> >> With Regards
> >> Deoki Nandan Vishwakarma
> >> IITR MCA
> >> Mathematics Department
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
>
>
>
> --
> Cheers,
> hammett
> http://hammett.castleproject.org/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to