C:\Users\86131\Desktop\c++\练习.cpp(23) : error C2143: syntax error : missing ';' before 'return'
毕业设计
1
#include<iostream>
using namespace std;
class Box
{
public:
Box();
Box(int w,int h,int l);
Box(const Box &other);
int V();
int CV(Box other);
private:
int width;
int longth;
int hight;
};
Box::Box():width(1),longth(1),hight(1){};
Box::Box(int l,int w,int h){width=w;longth=l;hight=h;}
Box::Box(const Box &other){width=other.width;longth=other.longth;hight=other.hight;}
int Box::V(){return width*longth*hight;}
int Box::CV(Box other){
if(this->V()>other.V())return 1;
else if(this->V()==other.V())return 0;
else (this->V()<other.V())return -1;
}
int main(){
Box s1;
Box s2(2,8,6),s3(6,3,8);
cout<<"s1体积为:"<<s1.V<<endl<<"s2体积为:"<<s2.V<<endl<<"s3体积为:"<<s3.V<<endl;
if(s2.CV(s3)>0)cout<<"s2体积大于s3"<<endl;
if(s2.CV(s3)==0)cout<<"s2体积等于s3"<<endl;
if(s2.CV(s3)<0)cout<<"s2体积小于s3"<<endl;
return 0;
}
运行结果及报错内容
C:\Users\86131\Desktop\c++\练习.cpp(23) : error C2143: syntax error : missing ';' before 'return'
我现在在计算体积和比较体积,但是提示我缺;但我没发现哪里缺。
发表回复