#include <oistream>
using namespace std; class A
{
public:
void foo()
{
func();
}
virtual void func()
{
cout<<"a"<<endl;
}
} class B : public A
{
public:
virtual void func()
{
cout<<"b"<<endl;
}
} void main()
{
B* b = new B;
b->foo();
}

运行结果是"b".我就当做是func()为this->func()了.

源头是cocos2dx的CCObject的copy()和copyWithZone().

use_virtual_func_without_pointer_left的更多相关文章

随机推荐

  1. spring初始化

    * Created by litao on 15/12/29. */@Component("initTagDataProcessor")public class InitTagDa ...

  2. [LeetCode#157] Read N Characters Given Read4

    Problem: The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is ...

  3. Leetcode 240. Search a 2D Matrix II

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  4. m2e使用问题——发布web项目时lib目录下的jar包未发布

    解决过程如下: 在项目上点右键查看properties—>Deployment Assembly,看Deploy Path这项上是否缺少WEB-INF/lib这一项. 相关操作截图如下:

  5. Linux下对拍脚本与随机数生成器

    对拍脚本 新建一个文档 check.sh 作为对拍脚本. #!/bin/bash while(true)do #死循环 ./data > .in #运行数据生成器,将数据输出到1.in ./st ...

  6. 详解Makefile 函数的语法与使用

    使用函数: 在Makefile中可以使用函数来处理变量,从而让我们的命令或是规则更为的灵活和具有智能.make所支持的函数也不算很多,不过已经足够我们的操作了.函数调用后,函数的返回值可以当做变量来使 ...

  7. GridControl控件添加按钮列及在按钮Click事件中得到行数据 zt

    在GridControl中添加按钮列的步骤如下: 1. 把列的ColumnEdit属性设置为RepositoryItemButtonEdit 2. 把TextEditStyle属性设置为HideTex ...

  8. Linux下Chrome浏览器的BUG

    “我胡汉三又回来了”,好久没出现在博客园了,准备考试什么的最烦躁了,今天又重新整了下我的Ubuntu,结果发现了一个Chrome浏览器的Bug,但是与其说它是个Bug,还不如说它是个Joke. 好吧, ...

  9. DATEDIFF()(转)

    SQL DATEDIFF 函数 Leave a reply SQL DATEDIFF() 函数用来返回2个时间的差.这个函数在SQL Server和MySQL中都有,但语法上有不同. SQL CASE ...

  10. 格式化URL

    //格式化url查询参数为json function formatUrl(url){ var reg=/(?:[?&]+)([^&]+)=([^&]+)/g; var data ...