那么类 Man 可以从类 Human 派生,类 Boy 可以从类 Man 派生
2024-10-21 00:09:30
若在逻辑上 B 是 A 的“一种”(a kind of ),则允许 B 继承 A 的功 能和属性。
例如男人(Man)是人(Human)的一种,男孩(Boy)是男人的一种。
那么类 Man 可以从类 Human 派生,类 Boy 可以从类 Man 派生。
#include <iostream>
#include<string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
//显示数组的函数模板
template <class T> void arr_put(T arr[],int size) {
for (int i= ;i<=size;i++)
cout<<arr[i]<<" ";
cout<<endl;
} //选择排序数组的函数模板
template <class T> void sort(T arr[],int size) {
T temp;
int i,j;
for (i=;i<size;i++)
for (j=i+;j<=size;j++)
if (arr[i]<=arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
} int main(int argc, char** argv) {
//用排序函数模板处理int型数组
cout<<"int:"<<endl;
int a[]={,,,,,,,-};
arr_put(a,);
sort(a,);
arr_put(a,); //用排序函数模板处理double型数组
cout<<"double:"<<endl;
double x[]={1.2,2.1,1.414,1.732};
arr_put(x,);
sort(x,);
arr_put(x,); //用排序函数模板处理char类型数组
cout<<"char:"<<endl;
char str[];
cout<<"str:";
cin>>str;
int size=strlen(str);
arr_put(str,size);
sort(str,size);
arr_put(str,size);
return ;
}
最新文章
- Office2013插件开发Outlook篇(1)-- 第一个office2013插件
- ssh设置
- POJ3744Scout YYF I(求概率 + 矩阵快速幂)
- Housse Robber II | leetcode
- Unreal Engine 虚幻引擎宣布对开发者免费
- Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造
- [转]ASP.NET MVC Jquery Validate 表单验证的多种方式介绍
- VS中使用sqlite静态连接
- Linux下high CPU分析心得【非原创】
- linux常用命令(自我积累)
- java 面对对象(抽象 继承 接口 多态)
- phpStorm 新建文件SVN不提交的解决的方法
- SSH服务端配置、优化加速、安全防护
- 理解Python迭代对象、迭代器、生成器
- python 玩耍天地
- Spark基础-scala学习(四、函数式编程)
- JVM中对象的回收过程
- vue里router-link标签设置动态路由的3个方法
- 2018.07.22哨戒炮 II(树形dp)
- MySQL复制 -- 复制出错怎么办?
热门文章
- it-tidalwave-semantic-aux-1.0.13.jar下载
- Autofac3 在MVC4中的运用原理
- 模拟登陆百度 python
- python字符串操作大全
- docker sshd image problem, session required pam_loginuid.so, cann&#39;t login
- iOS-仿智联字符图片验证码
- 【LeetCode】73. Set Matrix Zeroes (2 solutions)
- jquery切换class
- 网页调用本地程序(Windows下浏览器全兼容)
- connect: Network is unreachable解決方法