分析模板分离编译
1 分析为什么模板不支持分离编译
1.1 程序编译的基本流程
下面是普通类分离编译的代码:
//*****************test.h******************
#pragma once
#include<iostream>
using namespace std;
#include<stdlib.h>
void fun();
//***************test.cpp******************
#include"Test.h"
void fun() // 对函数fun()进行定义
{
cout << "fun" << endl;
}
//***************main.cpp******************
#include"Test.h"
int main()
{
fun(); //调用fun()函数
system("pause");
return 0;
}
上面代码的编译过程如下图所示:
main.cpp包含的te