摘要: 关键字virtual用于父类方法,如果传了一个子类对象,并且子类重写了父类的这个virtual方法,就会调用子类的方法。传谁就调用谁,这个就是多态。#include<iostream> using namespace std; class Biological{ public: virtual vo 阅读全文
posted @ 2019-09-01 21:53 hiligei 阅读(169) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std; class Base{public: Base(){ cout<<"hello"<<endl; } Base (int _a ):base(_a){ // 将a赋值给base base++; cout << base << 阅读全文
posted @ 2019-09-01 19:43 hiligei 阅读(2122) 评论(0) 推荐(0) 编辑