`
隐形的翅膀
  • 浏览: 484689 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

STL基础

    博客分类:
  • STL
 
阅读更多
1. 为什么使用模板库
a. 推迟对某些类的选择,直到想用模板或者对模板进行专门化处理时,才使用模板

b. 允许程序员面对相似而又略有不同的特性时,更快的编写代码,提高开发效率

2. 使用 cout,cin

#include <iostream>
#include <stdio.h>
using namespace std

3. typedef oldtype new type

4. 函数需要使用外部变量,应该在使用前用关键字  extern ,它的有效范围从声明处到文件末尾

extern int A;

4. List

#include <list>

list<person> pList;

person temp;
temp.id=1;
temp.name="mike";
pList.push_back(temp)

list<person>::Iterator Iter;

for (Iter=pList.begin(); Iter!=pList.end; Iter++)
{
temp.clear();
temp = *Iter;
}

cin.get()
getchar()

5. 定义模板类

template <classType>

example

template <Class T>
class Bclass
{
public:
static int cout;
public:
static int GetCount(){
return count;
}

6. 静态成员的赋值
template <class T> int BClass<t>::count=0;

7. call

BClass<int> myo;
myo.getCount();
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics