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)

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++ )Interview in English - Virtual的更多相关文章

  1. (C++) Interview in English. - Constructors/Destructors

    Constructors/Destructors. 我们都知道,在C++中建立一个类,这个类中肯定会包括构造函数.析构函数.复制构造函数和重载赋值操作:即使在你没有明确定义的情况下,编译器也会给你生成 ...

  2. (C/C++) Interview in English - Basic concepts.

    Question Key words Anwser A assignment operator abstract class It is a class that has one or more pu ...

  3. (C/C++) Interview in English - Class

    Q: What is a class? A: A class is an expanded concept of a data structure: instead of holding only d ...

  4. (C/C++) Interview in English - Threading

    Q. What's the process and threads and what's the difference between them? A.  A process is an execut ...

  5. (C/C++) Interview in English - Points.

    Q: What is a dangling pointer? A: A dangling pointer arises when you use the address of an object af ...

  6. (C/C++) Interview in English. - Memory Allocation/Deallocation.

    Q: What is the difference between new/delete and malloc/free? A: Malloc/free do not know about const ...

  7. step 1:begin to identify something in english(to becaome a baby again)

    long long ago , i think if i want to improve my english especially computer english . i must do so m ...

  8. c++设计模式:模板模式

    模板模式和策略模式的区别: 模板方法模式的主要思想:定义一个算法流程,将一些特定步骤的具体实现.延迟到子类.使得可以在不改变算法流程的情况下,通过不同的子类.来实现“定制”流程中的特定的步骤. 策略模 ...

  9. C# Interview Questions:C#-English Questions

    This is a list of questions I have gathered from other sources and created myself over a period of t ...

随机推荐

  1. Spring AOP 实现功能权限校验功能

    版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[-] 使用拦截器实现未登录时跳转到登录界面的功能 1 拦截器SecurityInterceptor 2spring-mvcxml拦 ...

  2. 怎么设置session无响应超时时间并且自动返回登陆页面

    ------解决方案--------------------看下我的 session.setAttribute(UserInfo.USERINFO, userinfo); session.setMax ...

  3. JavaWeb学习记录(十三)——商城购物之添加订单的数据库级联操作

    一.方法实现 private JdbcTemplate jdbcTemplate = new JdbcTemplate(DBConn.getDataSource()); @SuppressWarnin ...

  4. Linux驱动设计——阻塞和同步

    阻塞和非阻塞是设备访问的两种基本方式,阻塞和非阻塞驱动程序使用时,经常会用到等待队列. 阻塞和非阻塞 阻塞操作是指在执行设备操作时,若不能获得资源,则挂起进程直到满足可操作的条件后再进行操作.被挂起的 ...

  5. EXT3_DX_ADD_ENTRY: DIRECTORY INDEX FULL!

    inode问题故障1例故障关键字:ext3_dx_add_entry: Directory index full! 线上业务的一台服务器无缘无故突然挂了让机房帮忙连接显示器后发现报错 http://i ...

  6. C#中的预处理指令

    C#中的预处理指令 作为预处理中的一对:#region name ,#endregion可能是大家使用得最多的,我也常用它来进行代码分块,在一个比较长的cs文件中,这么做确实是一件可以让你使代码更清晰 ...

  7. maxscript, 数组和字符串下标是从1开始的

    maxscript中数组和字符串下标是从1开始的.

  8. ASP.NET 3.5 中实现发送email电子邮件

    来源:红黑联盟 方法1:cs代码 using System.Net.Mail; using System.Net; string mailServerName = "smtp.qq.com& ...

  9. OpenJudge计算概论-能被3,5,7整除的数

    /*===================================== 能被3,5,7整除的数 总时间限制: 1000ms 内存限制: 65536kB 描述 输入一个整数,判断它能否被3,5, ...

  10. wikioi 2235 机票打折 【考查浮点数四舍五入的技巧】

    /*======================================================================== 2235 机票打折 题目描述 Descriptio ...