上一页 1 ··· 12 13 14 15 16

2008年11月8日

模板——链表模板、有序链表模板及测试

摘要: //==============================================================================//链表模板《C++编程——数据结构与程序设计方法》16.2作为抽象数据类型的链表//Header File:linkedList.h#ifndef _LINKEDLIST_H#define _LINKEDLIST_Htemplate<class Type>struct nodeType{Type info;nodeType<Type>* link;};template<class Type>clas 阅读全文

posted @ 2008-11-08 17:18 WestGarden 阅读(366) 评论(0) 推荐(0) 编辑

模板——类模板

摘要: //《C++编程——数据结构与程序设计方法》15.8.3#include<iostream>#include <string>#include "arrayListType.h"using namespace std;template<class elemType>arrayListType<elemType>::arrayListType(int size)//(int size=100)是错的??{if(size<0){cout<<"Thearray size must be positive 阅读全文

posted @ 2008-11-08 02:49 WestGarden 阅读(168) 评论(0) 推荐(0) 编辑

模板——函数模板

摘要: //《C++编程——数据结构与程序设计方法》例15.8//利用函数重载技术,求两个整数、字符、浮点数或字符串中的较大值,需要编写4个函数larger。//而C++通过提供函数模板,简化了重载函数据的过程。#include <iostream>using namespace std;template<class Type>//Type,模板的形参,用于确定函数的形参,返回值类型,还用于在函数中声明变量。Type larger(Type x,Type y);int main(){cout<<"Line 1: Larger of 5 and 6 =&qu 阅读全文

posted @ 2008-11-08 00:12 WestGarden 阅读(134) 评论(0) 推荐(0) 编辑

上一页 1 ··· 12 13 14 15 16

导航