Why are virtual functions in C ++ called "virtual"?

So, I am new to the concept of virtual functions in C ++, and topics such as sell this concept pretty well. Well, I am convinced.

But why are virtual functions called "virtual"? I mean, such functions are "specific" like regular functions / methods, right? If someone can explain the choice of the word "virtual" to denote this concept, that would be great.

+6
source share
2 answers

Virtuality, the quality of the presence of attributes of something that does not share its (real or imagined) physical form

^ http://en.wikipedia.org/wiki/Virtual

A C ++ virtual function looks like a regular function ("having attributes"), but the implementation that will be called will not be propagated through the declaration or, if it does, using the built-in implementation.

+9
source

“virtual function” means a member function where a particular implementation will depend on the type of object it is accessing at runtime. The compiler and language runtime support allow this.

The keyword "virtual" in C ++ was taken from Simula, which impressed Bjarne Stroustrup. There is more background: Pure virtual or abstract, what's in the title?

.. The common base language SIMULA 67 (1970) .. seems to be the first language that introduces the OO keywords as a class, object, and virtual as a formal concept.

+6
source

Source: https://habr.com/ru/post/921032/


All Articles