【发布时间】:2012-02-27 00:10:37
【问题描述】:
我正在尝试使用 MS Visual Studio Professional 2010 编译此代码,它给了我一个构建错误 LNK1120 Fatal Error: 1 unresolved externals。 这是代码...
// Program Typos prints three integer numbers, sums the numbers, calculates
// the average, and prints the sum and the average of the three numbers.
#include <iostream>
#include <iomanip>
using namespace std;
const int ONE = 5;
const int TWO = 6;
const int THREE = 7;
int main ()
{
int sum;
float average;
cout << fixed << showpoint;
cout << setw(5) << ONE << TWO << THREE << endl;
sum = ONE + TWO + THREE;
average = sum / 3;
cout << " The sum is " << sum << " and the average is " \
<< average <<endl;
return 0;
}
【问题讨论】:
-
什么是未解决的外部?这编译得很好。
-
你的错误在别处。你没有充分准备这个问题。
-
在您的问题中,您将平均值计算为整数。在这种特殊情况下,这恰好可以解决,但这只是巧合。
标签: c++ visual-c++