一个程序连接问题!!!
代码如下:
#include <iostream>
using std::cout;
using std::endl;
struct Box{
double length;
double width;
double height;
};
double volume(const Box& aBox);
int main(){
Box firstBox={80.0,50.0,40.0};
double firstBoxVolume=volume(firstBox);
cout < <endl;
cout < < "Size of first Box object is "
< <firstBox.length < < " by "
< <firstBox.width < < " by "
< <firstBox.height
< <endl;
cout < < "Volume of first Box object is " < <firstBoxVolume
< <endl;
Box secondBox=firstBox;
secondBox.length*=1.1;
secondBox.width*=1.1;
secondBox.height*=1.1;
cout < < "Size of second Box object is "
< <secondBox.length < < " by "
< <secondBox.width < < " by "
< <secondBox.height
< <endl;
cout < < "Volume of second box object is " < <volume(secondBox)
< <endl;
cout < < "Increasing the box dimensions by 10% has increased the volume by "
< <static_cast <long> ((volume(secondBox)-firstBoxVolume)*100.0/firstBoxVolume)
< < "% "
< <endl;
return 0;
}
double volume(const Box& aBox){
return aBox.length*aBox.width*aBox.height;
}
我用的是VC6,编译能通过,但连接却出问题,提示如下:
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/11_1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
这是什么原因啊,请各位高手指点,谢谢!!!
[解决办法]
估计你在创建Project时选择的不是Win32 Console,而是Win32