哪里有错误啊?#includeusing namespace std;class Rectangle{public:{int width,height;}private:{ void r2(int w,int h)int area()};void Rectangle::r2(int w,int h){width=w;height=h;}Rectangle::area() {return width * height;}int main(){Rectangle r1r1.r
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/16 17:55:28
哪里有错误啊?
#include
using namespace std;
class Rectangle
{
public:
{int width,height;}
private:
{ void r2(int w,int h)
int area()
};
void Rectangle::r2(int w,int h)
{width=w;height=h;}
Rectangle::area() {return width * height;}
int main()
{
Rectangle r1
r1.r2(3,5) ;
cout
1、我实在搞不懂,你都已经会写类了,居然还会忘了写分号
很多地方,我就不一一列举了
2、属性设为私有,方法设有公有.你却恰好相反,另外公有私有不要用大括号括起来,放在后面系统就会分辨.
3、 Rectangle::area() {return width * height;}前面少了函数类型int
编程要细心.
最后完整的代码如下:
#include
using namespace std;
class Rectangle
{
private:
int width, height;
public:
void r2(int w, int h);
int area();
};
void Rectangle::r2(int w, int h)
{
width=w;
height=h;
}
int Rectangle::area()
{
return width * height;
}
int main()
{
Rectangle r1;
r1.r2(3,5) ;
cout
哪里有错误啊?#includeusing namespace std;class Rectangle{public:{int width,height;}private:{ void r2(int w,int h)int area()};void Rectangle::r2(int w,int h){width=w;height=h;}Rectangle::area() {return width * height;}int main(){Rectangle r1r1.r
这句话哪里有错误啊?
连线哪里有错误啊?(物理)
it is small monkey哪里有错误
are you a teacher?哪里有错误?
有错误吗 错在哪里了?
i has a rabbit哪里有错误
those watches are their.哪里有错误?
这个程序哪里错了啊?#include#includeusing namespace std;int main(){int A,B,C,D,E,F;for(A=0;A
一般生活中的常识与生活中常见的错误观念. 哪里有详细的啊?
天街小雨酥,草色遥看无这句诗哪里有错误?找出错误,有完整诗句更好!
我们中队图书馆角里有等杂志哪里有错误怎
I don't like eggs and meat.哪里有错误?
Is she birthday in july?哪里有错误
求英语老师帮我看看作文哪里有错误❓
More than one American child dislike getting 哪里有错误
he's playing the chess 哪里有错误
Is there a apple on the table哪里有错误