无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
skopt 2011-08-21 07:20:39 用VS2008建了一个控制台程序,编译后提示:
1>正在链接...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
1>E:\Visual Studio Project\MyC++Projects\01_DataStruct\TemplateTest\Debug\TemplateTest.exe : fatal error LNK1120: 1 个无法解析的外部命令
查了一些方法,都没用,实在没招了,哪位给给解决下吧,先谢了!!!!
代码如下:(写了一个CMyMath类)
------------MyMath头文件
#pragma once
template <typename Type>
class CMyMath
{
public:
CMyMath(void);
~CMyMath(void);
private:
Type a;
Type b;
public:
Type Add(Type a,Type b);
};
------------MyMath源文件
#include "StdAfx.h"
#include "MyMath.h"
template <typename Type>
CMyMath<Type>::CMyMath(void)
{
}
template <typename Type>
CMyMath<Type>::~CMyMath(void)
{
}
template <typename Type>
Type CMyMath<Type>::Add(Type a,Type b)
{
return a+b;
}
-------------main函数
#include "stdafx.h"
#include <iostream>
#include "MyMath.h"
using namespace std;
template <typename Type>
int _tmain(int argc, _TCHAR* argv[])
{
int a=1,b=2,c;
CMyMath<int> myMath;
c=myMath.Add(a,b);
cout<<c<<endl;
cin.get();
return 0;
}
还有,当把所有的代码写到一个文件里的时候也不提示错误。