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();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值