摘要:
// 第二十三模板 7复杂类模板/*#include <iostream>using namespace std;const int size=10;class people{public: people(int i):x(i){}; people():x(0){} int GetAge()const{ return x;} void show()const{cout<<x<<endl;}private: int x;};template <class T>class num{public: num(int Tsize=size); //带一个整 阅读全文
posted @ 2012-10-04 19:55
简单--生活
阅读(441)
评论(0)
推荐(0)
摘要:
//第二十三模板 3具体化函数模板//具体化函数模板, 顾名思义, 即具体化了函数参数和功能的模板//1 函数模板不能重载/*#include <iostream>using namespace std;template <class T>void Swap(T &a, T &b);struct people{ char name[10]; int age;};void show(people &p);int main(){ int i=10,j=20; cout<<"初始值i="<<i<< 阅读全文
posted @ 2012-10-04 19:54
简单--生活
阅读(332)
评论(0)
推荐(0)
摘要:
//第二十三模板 1什么是模板/*//未使用模板程序#include <iostream>using namespace std;void swap(int &rx, int &ry){ int temp = rx; rx = ry; ry = temp;}void swap(float &rx, float &ry){ float temp = rx; rx = ry; ry = temp;}void swap(double &rx, double &ry){ double temp = rx; rx = ry; ry = temp 阅读全文
posted @ 2012-10-04 13:36
简单--生活
阅读(153)
评论(0)
推荐(0)
摘要:
//第二十三模板 2重载模板/*#include <iostream>using namespace std;const int num=10;template<class T>void Swap(T&rx, T&ry){ cout<<"执行函数 void Swap(T &rx, T &ry)"<<endl; T temp = rx; ry = rx; rx = temp;}template<class T>void Tswap(T ar1[], T ar2[], int num){ 阅读全文
posted @ 2012-10-04 13:36
简单--生活
阅读(123)
评论(0)
推荐(0)