0
rahul.mca2001's Avatar, Join Date: Feb 2008
Ambitious contributor
congrats sir
0
nerdpower's Avatar
Newbie Member
This article is wrong ! The method the author describes only works for particular C++ compilers. Also the method used here is machine specific. The author has made assumptions on the size of the integer pointer which changes on different platforms. Its cool to tinker and find out how your compiler implements virtual function but this is not the same for all compilers and platforms.

There is **NOTHING** in the C++ Standard i.e. ISO/IEC 14882 (2003) that mentions how they are to be implemented. There are different ways to implementing virtual tables/pointers internally. If you want to understand how virtual functions (polymorphism) work pickup the ISO standard and start reading.
0
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
Quote:
Originally Posted by nerdpower
This article is wrong ! The method the author describes only works for particular C++ compilers. Also the method used here is machine specific. The author has made assumptions on the size of the integer pointer which changes on different platforms. Its cool to tinker and find out how your compiler implements virtual function but this is not the same for all compilers and platforms.

There is **NOTHING** in the C++ Standard i.e. ISO/IEC 14882 (2003) that mentions how they are to be implemented. There are different ways to implementing virtual tables/pointers internally. If you want to understand how virtual functions (polymorphism) work pickup the ISO standard and start reading.
I have already read the ISO standard, after reading i thought about it. I make it and test
on solaris system. This article gives you a idea about VPTR.

Can you tell me any compiler which is behaving different that whatever i descrived?
Offcourse compiler can implement any concept in different ways. Just go and read Iso standard for VPTR how it's designed?
0
alramesh's Avatar
Go4Expert Member
Quote:
Originally Posted by nerdpower
This article is wrong ! The method the author describes only works for particular C++ compilers. Also the method used here is machine specific. The author has made assumptions on the size of the integer pointer which changes on different platforms. Its cool to tinker and find out how your compiler implements virtual function but this is not the same for all compilers and platforms.

There is **NOTHING** in the C++ Standard i.e. ISO/IEC 14882 (2003) that mentions how they are to be implemented. There are different ways to implementing virtual tables/pointers internally. If you want to understand how virtual functions (polymorphism) work pickup the ISO standard and start reading.

what's wrong. I got everything . I think you did'nt read c++ standard.
0
nerdpower's Avatar
Newbie Member
Quote:
Originally Posted by alramesh
what's wrong. I got everything . I think you did'nt read c++ standard.
VPTR is nothing to do with the C++ Specification.
0
nerdpower's Avatar
Newbie Member
Quote:
Originally Posted by asadullah.ansari
I have already read the ISO standard, after reading i thought about it. I make it and test
on solaris system. This article gives you a idea about VPTR.

Can you tell me any compiler which is behaving different that whatever i descrived?
Offcourse compiler can implement any concept in different ways.
http://www.thefreecountry.com/compilers/cpp.shtml

Are you sure that your explanation works for all these compilers?

IIRC, this wont work with MSVC. I have no problem with your explanation, you should mention that it will only work for x,y,z compiler under a,b,c platform. If you don't mention that, people reading your article will assume that this is a global standard for all C++ compilers.
Quote:
Originally Posted by asadullah.ansari
Just go and read Iso standard for VPTR how it's designed?
What ISO standard? Can you quote the actual standard that describes the size of vptr as 4 bytes? You can also define vtbl in different ways.
0
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
Quote:
Originally Posted by nerdpower
http://www.thefreecountry.com/compilers/cpp.shtml

Are you sure that your explanation works for all these compilers?

IIRC, this wont work with MSVC. I have no problem with your explanation, you should mention that it will only work for x,y,z compiler under a,b,c platform. If you don't mention that, people reading your article will assume that this is a global standard for all C++ compilers.

Can you quote the actual standard that describes the size of vptr as 4 bytes? You can also define vtbl in different ways.


i have mention above it's for 32 bit machine
0
talk2mohdsaif's Avatar, Join Date: Mar 2009
Go4Expert Member
Very Nice artical bro..........................
0
talk2mohdsaif's Avatar, Join Date: Mar 2009
Go4Expert Member
really nice article..
i was confusion in vtable but now i know all about vtable and vptr.......