STL入门——函数模板基本语法

// 01stl_template.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include 

using namespace std;

template   //语法template  //告诉编译器,我下面写模板函数
void MySwap(T&a, T &b)
{

	T temp = a;
	a = b;
	b = temp;
}

void test01(){
	int a = 10;
	int b = 20;
	//自动类型推导
	cout<<"a:"<(a,b);
	
	cout<<"a:"<

模板技术,类型参数化,编写代码可以忽略类型

 

你可能感兴趣的:(STL入门——函数模板基本语法)