一个经典教程上的C++程序例子,输入计算机编译却有问题,请高手指点?

来源:百度知道 编辑:UC知道 时间:2024/06/04 06:37:45
#include <iostream>
using namespace std;
class Box
{
public:
Box(double lv=1,double wv=1,double hv=1);
virtual ~Box();
void showVolume() const;
virtual double volume() const;
friend ostream& operator <<(ostream &out,const Box &rBox);
protected:
private:
double length;
double width;
double height;
};
Box::Box(double lv,double wv,double hv):length(lv),width(wv),height(hv){

}
Box::~Box(){
}
void Box::showVolume() const{
cout<<endl<<"Box useable volume is "<<volume();
}
double Box::volume() const{
return length*width*height;
}
ostream& operator <<(ostream &out,const Box &rBox)
{
return out<<' '<<rBox.length<<' '<<rBox.width<<' '<<rBox.height;
}
int main()
{
Box bigbox(50,60,70);
Box smallbox(2,3,4);

vc6.0会有错,用其他的编译好象都不会有错

VC2008,无任何错误:
------ Build started: Project: node, Configuration: Debug Win32 ------
Compiling...
main.cpp
Linking...
LINK : warning LNK4076: invalid incremental status file 'E:\Documents\Visual Studio 2008\Projects\node\Debug\node.ilk'; linking nonincrementally
Embedding manifest...
Build log was saved at "file://e:\Documents\Visual Studio 2008\Projects\node\node\Debug\BuildLog.htm"
node - 0 error(s), 1 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

bigbox is 50 60 70 2 3 4请按任意键继续. . .

--------------------Configuration: mingw2.95 - CUI Debug, Builder Type: MinGW (Old)--------------------

Checking file dependency...
Compiling C:\PROGRA~1\C-FREE~1\temp\Untitled3.cpp...
Linking...

Complete Make Untitled3: 0 error(s), 0 warning(s)
Gene