体积输出问题
#include<iostream>using namespace std;
class Box
{ public:
Box(int,int,int);
int volume();
void display();
private:
int height;
int width;
int length;
};
Box::Box(int h,int w,int len):height(h),width(w),length(len){}
int Box::volume()
{return (height*width*length);}
void Box::display()
{cout<<volume()<<endl;}
int main()
{ Box box1(15,20,30);
cout<<box1.volume<<endl;
cout<<box1.display<<endl;
return 0;
}
,长,宽,高我分别赋值15,20,30,为什么程序的输出结果是1呢??