【C++ Primer | 19】运行类型识别

2021-07-16 01:07

阅读:420

标签:http   ase   int   prime   eid   void   space   stream   out   

type_info类

测试代码:

 1 #include  2 #include  3 
 4 class Base {
 5 public:
 6     virtual void vvfunc() {}
 7 };
 8 
 9 class Derived : public Base {};
10 
11 using namespace std;
12 int main() {
13     Derived* pd = new Derived;
14     Base* pb = pd;
15     cout //prints "class Base *"  
16     cout //prints "class Derived"  
17     cout //prints "class Derived *"  
18     cout //prints "class Derived"  
19     delete pd;
20 }

输出结果:
技术分享图片

 

【C++ Primer | 19】运行类型识别

标签:http   ase   int   prime   eid   void   space   stream   out   

原文地址:https://www.cnblogs.com/sunbines/p/9535448.html


评论


亲,登录后才可以留言!