C++虚函数示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
 
using namespace std;
 
class P{
public:
    P * m_p;
    P(){
        this->m_p=this;
    }
    virtual void Intro(){
        cout<<"this is P"<<endl;
    }
};
 
class S:public P{
public :
    virtual void Intro(){
        cout<<"this is S"<<endl;
    }
};
 
S s;
 
int  main(){
    s.Intro();
    s.m_p->Intro();
    return 0;
}

 

posted @   庚武  Views(191)  Comments(0Edit  收藏  举报
编辑推荐:
· ASP.NET Core 模型验证消息的本地化新姿势
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
阅读排行:
· C# 中比较实用的关键字,基础高频面试题!
· 为什么AI教师难以实现
· 如何让低于1B参数的小型语言模型实现 100% 的准确率
· AI Agent爆火后,MCP协议为什么如此重要!
· 【译】Visual Studio(v17.13)中新的调试和分析特性
历史上的今天:
2011-02-18 ret and retf
2011-02-18 寄存器寻址方式
2011-02-18 CodeView 4.01
2011-02-18 vs6 sp6下载网址 Visual Studio 6
2011-02-18 win32常见寄存器register
点击右上角即可分享
微信分享提示