主题:急求LNK1120问题
我用的是Microsoft Visual studio 2010。编译下面的程序时出现fatal error LNK1120: 1 unresolved externals这个问题,程序应该是不会错的,因为程序是C++ Primer上照抄的,请问高手如何解决LNK1120的问题
#include<iostream>
#include<vector>
using namespace std;
int mian()
{
int ival;
vector<int> ivec;
cout<<"enter numbers(Ctrl+z to end)"<<endl;
while(cin>>ival)
{
ivec.push_back(ival);
}
if(ivec.size()==0)
{
cout<<"no element"<<endl;
return -1;
}
cout<<"sum of each pair of adjacent elements in the vector:"<<endl;
vector<int>::size_type cnt=0;
for(vector<int>::iterator iter=ivec.begin();iter<ivec.end()-1;iter=iter+2)
{
cout<<*iter+*(iter+1)<<endl;
++cnt;
if(cnt%6==0)
cout<<endl;
}
if(ivec.size()%2!=0)
{
cout<<"最后一个元素没参加计算,这个值为"<<*(ivec.end()-1)<<endl;
}
return 0;
#include<iostream>
#include<vector>
using namespace std;
int mian()
{
int ival;
vector<int> ivec;
cout<<"enter numbers(Ctrl+z to end)"<<endl;
while(cin>>ival)
{
ivec.push_back(ival);
}
if(ivec.size()==0)
{
cout<<"no element"<<endl;
return -1;
}
cout<<"sum of each pair of adjacent elements in the vector:"<<endl;
vector<int>::size_type cnt=0;
for(vector<int>::iterator iter=ivec.begin();iter<ivec.end()-1;iter=iter+2)
{
cout<<*iter+*(iter+1)<<endl;
++cnt;
if(cnt%6==0)
cout<<endl;
}
if(ivec.size()%2!=0)
{
cout<<"最后一个元素没参加计算,这个值为"<<*(ivec.end()-1)<<endl;
}
return 0;