@CrazyHenry
2018-02-22T17:26:27.000000Z
字数 798
阅读 1065
ccccC++Primer
- Author:李英民 | Henry
- E-mail: li
_
yingmin@
outlookdot
com- Home: https://liyingmin.wixsite.com/henry
快速了解我: About Me
转载请保留上述引用内容,谢谢配合!
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include <memory>
#include <initializer_list>
using namespace std;
//win+<-/-> 切换窗口位置
//ctrl+win+<-/->切换桌面
//ctrl+alt+上/下 改变显示器方向
class Test
{
public:
virtual int func() {cout<<"Test"<<endl;}
};
class Test1:public Test
{
public:
virtual int func()=0;
};
inline
int Test1::func()
{
cout<<"Test1"<<endl;
}
class Test2:public Test1
{
public:
virtual int func() override;
};
inline int Test2::func()
{
cout<<"Test2"<<endl;
Test::func();
Test1::func();
}
int main()
{
Test2 t2;
Test *p = &t2;
p->func();
return 0;
}
如果不定义,调用了将会发生系统级编译错误!
一般不要随意定义和调用纯虚函数,纯虚函数调用是没有意义的!