我寫了這個程序,但它不起作用。它給出了一個錯誤,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;' –