大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

(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-创新互联
URL标题:http://dzwzjz.com/article/pjijh.html
在线咨询
服务热线
服务热线:028-86922220
TOP