We always declare a pure virtual work as :
virtual void fun () =
i.e. it is usually designated to .
Things I understand is this fact would be to initialize the vtable entry for this reason to NULL and then any other value here produces a compile time error. Please let me know whether this understanding is correct or otherwise.
The main reason
= can be used is the fact that Bjarne Stroustrup did not think he might get another keyword, for example "pure" beyond the C++ community at that time the feature had been implemented. This really is referred to in the book, The Look &lifier Evolution of C++, section 13.2.3:
The curious = syntax was selected ... because at that time I saw absolutely no way of obtaining a new keyword recognized.
Younger crowd states clearly this do not need to set the vtable admission to NULL, which doing this isn't the easiest way of applying pure virtual functions.
Associated with pension transfer "Why" questions regarding the appearance of C++, the to begin with to appear is The Look and Evolution of C++, by Bjarne Stroustrup1:
=syntax was selected within the apparent alternative of presenting a brand new keyword
abstractbecause at that time I saw absolutely no way of having a brand new keyword recognized. Had I recommended
pure, Release 2. might have shipped without abstract classes. Given an option from a better syntax and abstract classes, I selected abstract classes. Instead of jeopardizing delay and taking on the certain fights over
pure, I made use of the tradition C and C++ convention of utilizing to represent "not there." The
=syntax fits with my view that the function is the initializer for any function also with the (simplistic, truly sufficient) look at the group of virtual functions being implemented like a vector of function pointers. [ ... ]
I am unsure if there's any meaning behind this, it is only the syntax from the language.
Section 9.2 from the C++ standard provides the syntax for class people. It offers this production:
There's nothing special concerning the value. "= " is only the syntax for saying "this function is pure virtual."
C++ must have the means to distinguish a pure virtual function from the promise of an ordinary virtual function. They made a decision to make use of the
= syntax. They might simply have easily done exactly the same with the addition of a pure keyword. But C++ is fairly loath to include new key phrases and favors to make use of other systems introducing features.
There is nothing "initilaized" or "designated" zero within this situation.
= in a syntactical construct composed of
tokens, that has simply no regards to either initialization or assignment.
It's no regards to any actual value in "vtable". The C++ language doesn't have perception of "vtable" or anythng like this. Various "vtables" are simply just particulars of specific implementations.
I recall reading through the justification for that funny syntax was it was simpler (when it comes to standards-acceptance) than presenting another keyword that will perform the same factor.
In my opinion it was pointed out within the Design and Evolution of C++ by Bjarne Stroustrup.
I'd think that case area of the C++ grammar. I do not think you will find any limitations to the way the compilers really implement this for any given specific binary format. You are assumption most likely was suitable for the first day C++ compilers.
= declares a pure virtual function.
What's understand is this fact would be to initialize the vtable entry for this reason to NULL and then any other value here leads to compile time error
I do not think that's true. It is simply special syntax. The vtable is implementation-defined. Nobody states a vtable entry for any pure member should be really zeroed upon construction (although most compilers handle vtables similar).