求助,这个是什么问题
c吧
全部回复
仅看楼主
level 3
gkgkf🌿 楼主
2022年12月10日 05点12分 1
level 3
gkgkf🌿 楼主
前面是设计了一个Rectangle的类
2022年12月10日 05点12分 2
level 3
gkgkf🌿 楼主
#include<windows.h>
#include<iostream>
usingnamespacestd;
classRectangle{
private:
doublem_length=1;
doublem_width=1;
public:
doublePerimeter(){return2*(m_length+m_width);}
doubleArea(){returnm_length*m_width;}
voidSetWidth(doublew){m_width=w;}
doubleGetWidth(){returnm_width;}
voidSetLength(doublel){m_length=l;}
doubleGetLength(){returnm_length;}
boolSet_(){
booln=1;
if(0>m_length||20<m_length){
cout<<"lengthisnotin0.0-20.0"<<endl;
n=0;
}
if(0>m_width||20<m_width){
cout<<"widthisnotin0.0-20.0"<<endl;
n=0;
}
if(n)
cout<<"lengthandwidtharebothin0.0-20.0"<<endl;
returnn;
}
};
intmain(){
Rectanglerec;
cout<<"Length:"<<rec.GetLength()<<""<<"Width:"<<rec.GetWidth()<<endl;
rec.Set_();
cout<<endl<<endl;
rec.SetLength(5.2);
rec.SetWidth(4);
cout<<"Length:"<<rec.GetLength()<<""<<"Width:"<<rec.GetWidth()<<endl;
rec.Set_();
cout<<endl<<endl;
rec.SetWidth(25);
cout<<"Length:"<<rec.GetLength()<<""<<"Width:"<<rec.GetWidth()<<endl;
rec.Set_();
cout<<endl<<endl;
return0;
}
2022年12月10日 05点12分 4
level 3
gkgkf🌿 楼主
2022年12月10日 05点12分 5
level 6
你这个类名是编译器内部定义过的了,类名改个名字就好了
2022年12月10日 06点12分 6
level 3
给你的类换个合法名字,原来的与windows.h里的函数冲突了。
2022年12月10日 18点12分 7
1