简体   繁体   中英

Are virtual tables part of the C++ standard?

I am reading about the implementation of late binding polymorphism in C++ and I learned about virtual tables and virtual pointers.

Then I searched on the C++ standard ( ISO/IEC 14882:2011 ) to get more information about how this behavior should be implemented.

Unfortunately I found nothing relevant in this massive standard except the definition of Virtual functions at §10.3 so I suppose the concept of __vptr is used by GCC but could be implemented differently.

Is there a standard or a paper that describe how virtual methods should be implemented?

No they are not defined by the standard. They are instead implementation concepts, rather like a stack or a heap .

The standard is helpful in permitting the implementation of polymorphism to be carried out in a certain way, for example, the address of the first member variable of a class doesn't need to be the address of an instance of that class if that class is a polymorphic type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM