我写了这个程序,但它不起作用。它给出了一个错误,x
和y
没有声明和预期主要表达式行int 17
之前的int。C++类不适合我
#include<iostream>
using namespace std;
class shapes
{
int width, height;
public:
int getvalue();
void decideshape(int l, int b);
};
main()
{
cout<<"to find what type of shape you have input the measurements"<<endl;
shapes toy;
toy.getvalue();
toy.decideshape();
}
int shapes::getvalue()
{
int l, b;
cout<<"length = ";
cin>>l;
cout<<"breath = ";
cin>>b;
}
void shapes::decideshape(x, y)
{
if(x==y)
cout<<"This is square"<<endl;
else
cout<<"This is rectangle"<<endl;
}
我应该如何从功能的GetValue
另外你定义一个返回类型为'的GetValue()'所以你需要就算返回一个整数,它是'return 0;' –