首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

编程初学者

2013-03-21 
编程菜鸟求助.我在写一个代码的时候。系统一直提示LINK : fatal error LNK1561: 必须定义入口点。但是我一直

编程菜鸟求助.
我在写一个代码的时候。系统一直提示LINK : fatal error LNK1561: 必须定义入口点。但是我一直发现不了问题在哪里。望大神帮忙解决。
附上源代码。

#include <iostream>
#include <vector>
#include <string>
using namespace std;
template <typename T>

void main()
{
int num;

cout << "please input the number of your data.\n";
cin >> num;

vector<T> v(num);

cout << "please input your data.\n";
for (int i=0;i<num;i++)
{
cin >> v[i];
};

cout << max(vector<T>);
}

int max(vector <int>)
{
vector <int> vMem;
vector <int>::iterator p;
int temp;

p=vMem.begin();
temp=*p;
for(;p!=vMem.end();p++)
{
if (temp<*p)
temp=*p;
}
return temp;
}

float max(vector <float>)
{
vector <float> vMem;
vector <float>::iterator p;
float temp;

p=vMem.begin();
temp=*p;
for(;p!=vMem.end();p++)
{
if (temp<*p)
temp=*p;
}
return temp;
}

string max(vector <string>)
{
vector <string> vMem;
vector <string>::iterator p;
string temp;

p=vMem.begin();
temp=*p;
for(;p!=vMem.end();p++)
{
if (temp<*p)
temp=*p;
}
return temp;
}


[解决办法]
main函数是模板?
这个可不行啊
[解决办法]
main函数作为程序的入口点,不能重新定义的,所以作为模版的main肯定是错的。在main中,其实你要做的,是要测试你的程序,所以需要把模版参数具体化了。比如vector<int>这样。

热点排行