The C++ ISO Standard says nothing about virtual function table pointer in the first place. A Compiler may follow this mechanism to support runtime-polymorphism or can come up with any other which doesn't even involve vptr Its entirely upto the compiler writers. Since the Standard doesn't say anything about vptr how can it say about its size?
No way. The conclusion is: what you're doing (or assuming) isn't gauranteed by the language. However, for a compiler, it might be always true As a sidenote, for your compiler, how can you conclude that sizeof(vft) will be equal to sizeof(vptr)?
It could very well be that sizeof(vft) > sizeof(vptr) I don't claim that though.
The C++ ISO Standard says nothing about virtual function table pointer in the first place. A Compiler may follow this mechanism to support runtime-polymorphism or can come up with any other which doesn't even involve vptr. Its entirely upto the compiler writers.
Since the Standard doesn't say anything about vptr, how can it say about its size? No way. The conclusion is: what you're doing (or assuming) isn't gauranteed by the language.
However, for a compiler, it might be always true. As a sidenote, for your compiler, how can you conclude that sizeof(vft) will be equal to sizeof(vptr)? It could very well be that sizeof(vft) > sizeof(vptr).
I don't claim that though.
Oh, vft is just a random name :) – neuront Aug 17 at 17:05 @neuront: I know that its "random" name. My point was, why should the size of class, be equal to the size of vptr? In your example, vft is a class name.
– Nawaz Aug 17 at 17:06 Just another assumption in my mind... – neuront Aug 18 at 1:19.
No, Virtualism is implementation defined. It is an compiler implementation detail. So you cannot say that will be true always.
Also, You should refrain yourself from writing any code(like the one in Question) that assumes an detail that is left open by the Standard as an compiler implementation detail, Because that makes your code not 100% portable across compilers & might even fail drastically on some compilers.
" Depends on what you mean by "always". As others have already pointed out, this is an implementation detail that is subject to change even with different versions of the same compiler. The C++ standard says nothing about it, so you can't rely on it.
On the other hand, I've never seen a compiler where this wouldn't be true.
I have. In the early days Virtual tables were still be tested and other techniques were used. – Loki Astari Aug 17 at 17:23.
Aside from the facts that everyone else already pointed out, I feel like the standard does give some guarantees. Namely, for class vft { void* a, b; virtual ~vft(); } then sizeof(vft) > sizeof(void*). I'm pretty sure the standard guarantees that much at least, virtual functions or no.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.