help!!!请大神帮我看下这段程序有什么问题
在VS2010下写了一个小程序,但是编译出错,不太明白什么问题,有谁懂得请指正下,谢了先~
#ifndef BASIC_ALGORITHMS_H#define BASIC_ALGORITHMS_H#include "stdafx.h"#include <vector>using namespace std;class BasicAlgorithms{public: template<typename Type> void InsertionSort(vector<Type> &);};#endif
#include "stdafx.h"#include "BasicAlgorithms.h"template <typename Type>void BasicAlgorithms::InsertionSort(vector<Type> &vec_to_sort){ vector<Type>::size_type i=0; for(vector<Type::size_type j=2;j<vec_to_sort.size();j++) { Type key=vec_to_sort[j]; i=j-1; while(i>0&&vec_to_sort[i]>key) { vec_to_sort[i+1]=vec_to_sort[i]; i--; } vec_to_sort[i+1]=key; }}
#include "stdafx.h"#include "BasicAlgorithms.h"#include <vector>#include <iostream>using namespace std;int _tmain(int argc, _TCHAR* argv[]){ vector<int> vec(20); int temp=0; for(vector<int>::size_type i=0;i<vec.size();i++) { temp=rand(); cout<<temp<<endl; vec.push_back(temp); } BasicAlgorithms ba; ba.InsertionSort(vec); for(vector<int>::size_type i=0;i<vec.size();i++) { cout<<vec[i]<<endl; } return 0;}