实验3
来源:互联网 发布:注册淘宝需要什么条件 编辑:程序博客网 时间:2024/05/08 03:06
头文件:
#ifndef HEAD_H
#define HEAD_H
template<typename T>
class A
{
public:
T add(T x, T y);
T multiply(T x, T y);
};
#endif
源程序:
main.app
#include<iostream>
using namespace std;
int main()
{
A<int> x;
A<float> y;
cout << "7+8=" << x.add(7,8) << endl;
cout << "9.3+3.4=" << y.add(9.3, 3.4) << endl;
cout << "7*8=" << x.multiply(7, 8) << endl;
cout << "9.3*3.4=" << y.multiply(9.3, 3.4) << endl;
system("pause");
return 0;
}
source.app
#include<iostream>
#include"HEAD.h"
#include<stdlib.h>
#include<iomanip>
using namespace std;
template<typename T>
T A<T>::add(T x,T y)
{
return x + y;
}
template<typename T>
T A<T>::multiply(T x, T y)
{
return x*y;
}
0 0
- 实验3
- 实验3
- 实验3
- 实验3
- 实验3
- 实验3
- 实验3
- 实验3
- 接口与实验:实验3
- 上机实验3种排序实验8
- C++实验2-剩下3个实验
- 实验:C++实验3-项目1
- 实验:c++实验3-项目1
- 实验:C++ 实验3-项目1
- 实验:C++实验3-个人所得税计算器
- 数据压缩原理实验3_实验报告
- 【实验报告】高软实验3
- 实验二线性表综合实验3
- 【codeforces】Codeforces Round #274 (Div. 2)
- SDN模拟环境floodlight+mininet配置过程
- 程序员写代码时应该反复问自己的10个问题
- mac apache 不支持php
- VMware安装以及ubuntu12.04 安装 #精简整理版##新手一看就会#
- 实验3
- android 设置背景图片 xml的background和java的getDrawable()
- PAT Advanced 1002
- 线性表实验
- android实现对通讯录增加和查询
- 实验1
- Android中的“再按一次返回键退出程序”实现
- 笔试题---消除多余的空格
- 设计模式之抽象工厂模式