(C/C++)InterviewinEnglish-Virtual-创新互联

Q: What is virtual function?
A: A virtual function or virtual method is a function or method whose behavior can be overridden within an inheriting class by a function with the same signature. This concept is an important part of the polymorphism portion of object-oriented programming (OOP)(C/C++)Interview
inEnglish-Virtual

Q: What is a "pure virtual" member function?
A: The abstract class whose pure virtual method has to be implemented by all the classes which derive on these. Otherwise it would result in a compilation error. This construct should be used when one wants to ensure that all the derived classes implement the method defined as pure virtual in base class.

为二道江等地区用户提供了全套网页设计制作服务,及二道江网站建设行业解决方案。主营业务为成都网站建设、成都网站设计、二道江网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

Q: How virtual functions are implemented C++?

A: Virtual functions are implemented using a table of function pointers, called the vtable. There is one entry in the table per virtual function in the class. This table is created by the constructor of the class. When a derived class is constructed, its base class is constructed _rst which creates the vtable. If the derived class overrides any of the base classes virtual functions, those entries in the vtable are overwritten by the derived class constructor. This is why you should never call virtual functions from a constructor: because the vtable entries for the object may not have been set up by the derived class constructor yet, so you might end up calling base class implementations of those virtual functions


网站栏目:(C/C++)InterviewinEnglish-Virtual-创新互联
文章转载:http://bzwzjz.com/article/pjijh.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站制作 重庆企业网站建设 网站设计 成都网站建设 网站制作公司 成都网站建设 网站建设公司 成都商城网站建设 网站建设改版 定制网站设计 网站建设 成都网站设计公司 成都网站制作 定制级高端网站建设 专业网站建设 成都网站制作 成都网站建设公司 外贸网站建设 成都网站建设公司 阿坝网站设计 手机网站设计 成都网站设计