第十四周项目 3 数组类模板
来源:互联网 发布:淘宝买东西领淘金币 编辑:程序博客网 时间:2024/04/30 23:09
/* *Copyright(c) 2016, 烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:main.cpp *作 者:李德坤 *完成日期:2016年5月29日 *版本号:v1.0 * *问题描述:数组类模板 *输入描述:无 *输出描述:无*/#include <iostream>#include<string>using namespace std;template <class T> //数组类模板定义class Array{private: T* list; //用于存放动态分配的数组内存首地址 int size; //数组大小(元素个数)public: Array(int s,T a[]); ~Array(); void display();};template <class T>Array<T>::Array(int s,T a[]){ size=s; list=new T[size]; list=a;}template <class T>Array<T>::~Array(){ delete [] list;}template <class T>void Array<T>::display(){ int i; for(i=0;i<size;i++) cout<<list[i]<<" ";}int main(){ int a1[5]={1,2,3,4,5}; string b1[5]={"a","b","c","d","e"}; Array<int> t1(5,a1); t1.display(); cout<<endl; Array<string> t2(5,b1); t2.display(); return 0;}
0 0
- 第十四周项目 3 数组类模板
- 第十四周项目四 数组类模板
- 第十四周项目三 数组类模板
- 第十四周项目61-数组类模板
- 第十四周项目61-数组类模板
- 第十四周项目4:数组类模板
- 第十四周项目三-数组类模板
- 第十四周项目三 数组类模板
- 第十四周项目三-数组类模板
- 第十四周项目三数组类模板
- 第十四周项目3—数组类模板
- 第十四周项目3—数组类模板
- 第十四周上机实践项目3:数组类模板
- 第十四周上机实践——项目3-数组类模板
- 第十四周实践项目3————数组类模板
- 第十四周——数组类模板
- 第十四周=--数组类模板
- 第十四周项目3:两个成员的类模板
- Fastjson内幕
- iOS开发真机调试证书导出.p12文件
- 数据结构—二叉树后序遍历求逆
- 网站的轮播图的获取
- Android线程的创建、开启、休眠、中断
- 第十四周项目 3 数组类模板
- Flume概述
- 判断php的运行模式
- 使用Apache CXF开发Web Service步骤
- 第1课时《Qt osgEarth 编程入门》
- Browsersync的简单使用
- Program3_U
- cmd进入 链接mysql注意事项
- C/C++上机指南