Not sure what you mean by class memory. Are you trying to distinguish
between class vs instances? If so, yes, I believe the vtable should be
per class, since the this pointer is probably the first one to be
pushed in non-static members call, it wouldnt make sense to have a
separated copy for each instance. I may be wrong here, though...

On Mon, Mar 28, 2011 at 1:31 PM, Amit Basak <[email protected]> wrote:
> 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 <[email protected]> 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
>> <[email protected]> wrote:
>> > can u gv any link for reference...???
>> >
>> > On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR
>> > <[email protected]>
>> > 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
>> >> <[email protected]> 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 [email protected].
>> >>> To unsubscribe from this group, send email to
>> >>> [email protected].
>> >>> 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 [email protected].
>> >> To unsubscribe from this group, send email to
>> >> [email protected].
>> >> 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 [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to