C++ Virtual Functions – Why No ‘Pure’ Keyword?

ckeywordssyntaxvirtual-functions

I have always wondered why we code

virtual void MyFunction() = 0; 

and not

pure virtual void MyFunction();

Is there a reference for the basis of this decision?

Best Answer

From The Design and Evolution of C++ - Bjarne Stroustrup - Addison-Wesley (ISBN 0-201-54330-3) - chapter 13.2.3:

The curious = 0 syntax was chosen over the obvious alternative of introducing a new keyword pure or abstract because at the time I saw no chance of getting a new keyword accepted. Had I suggested pure, Release 2.0 would have shipped without abstract classes. Given a choice between a nicer syntax and abstract classes, I chose abstract classes. Rather than risking delay and incurring the certain fights over pure, I used the tradition C and C++ convention of using 0 to represent not there.

Anyway looking at the C++ standard (ยง 9.2 - Class members) = 0 is called pure-specifier.