MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart

Ccamilee 2014-09-14 10:48:49
错误为:1>MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
1>C:\Users\Ccami\Desktop\seqlistprojecta\Debug\seqlistprojecta.exe : fatal error LNK1120: 1 个无法解析的外部命令
我之前通过在属性命令行加入了/nodefaultlib:libc,然后把找不到libc的错误消除了,但出现了以上的两个错误,
求大神解答,这是作业但我运行不了
Sealist.h
#ifndef SeqLIst_H
#define SeqLIst_H
const int MaxSize=100;
template<class DataType>
class SeqList
{public:
SeqList(){length=0;}
SeqList(DataType a[],int n);
~SeqList(){}
int length(){return length;}
DataType Get(int i);
int Locate(DataType x);
void Insert(int i,DataType x);
DataType Delete(int i);
void PrintList();
private:
DataType data[MaxSize];
int Length;};
#endif

SeqList.cpp
#include<iostream>
using namespace std;
#include"SeqList.h"
template<class DataType>
SeqList<DataType>::SeqList(DataType a[],int n)
{if(n>MaxSize)throw"参数非法";
for(i=0;i<n;i++)
data[i]=a[i];
length=n;}
template<class DataType>
DataType SeqList<DataType>::Get(int i)
{if(i<1||i>length)throw"查找位置非法";
else return data[i-1];}
template<class DataType>
int SeqList<DataType>::Locate(DataType x)
{for(i=0;i<length;i++)
if(data[i]==x)
return i+1;
return 0;}
template<class DataType>
void SeqList<DataType>::Insert(int i,DataType x)
{
if(length>=MaxSize)throw"上溢";
if(i<1||i>length+1)throw"位置";
for(j=length;j>=i;j--)
data[j]=date[j-1];
data[i-1]=x;
length++;}

SeqList_main.cpp
#include<iostream>
using namespace std;
#include"SeqList.h"
template<class DataType>
int main()
{int a[5],n=5;
for(int i=0;i<10;i++)
cin>>a[i];
SeqList(a[5],5);
SeqList::Insert(1,1);
SeqList::PrintList();
SeqList.PrintList();
SeqList<int> a;
a.Insert(1,10);
int b=a.get(1);
cout>>a;
}
...全文
534 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
光子乘羽 2014-10-25
  • 打赏
  • 举报
回复
我这里也出现了同样的错误,但是我还没有加main ()
Ccamilee 2014-10-19
  • 打赏
  • 举报
回复
我知道错误在哪里了, 1.代码编写错误 2.vs2008如果引用模版的话,是不能把头文件拆开来分别用.H和.CPP写
阿呆_ 2014-09-15
  • 打赏
  • 举报
回复
extern "C"将main包起来
Ccamilee 2014-09-15
  • 打赏
  • 举报
回复
引用 2 楼 bojie5744 的回复:
main 改为_tmain
还是不能呢
  • 打赏
  • 举报
回复
main 改为_tmain
  • 打赏
  • 举报
回复
int main() 改为 _tmain

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧