これが私の最初の投稿になりたくなかったのですが、ここで途方に暮れています。プログラムをコンパイルしようとすると、このエラーが発生し続けます (これは、単に長方形の面積と周囲を見つけることになっています)。これは私のヘッダー ファイルです。
#include <iostream>
using namespace std;
class Rectangle
{
public:
Rectangle(float Lngth=1, float Wdth = 1);
void setLngth(float Lngth);
void setWdth(float Wdth);
float getLngth(float Lngth);
float getWdth(float Wdth);
void Perimeter(float lngth, float wdth);
void Area(float lngth, float wdth);
private:
float Lngth;
float Wdth;
};
これは私の .cpp ファイルです。
#include <iostream>
using namespace std;
#include "RealRectangle.h" // Employee class definition
Rectangle::Rectangle(float Lngth, float Wdth)
{
&Rectangle::setLngth;
&Rectangle::setWdth;
}
void Rectangle::setLngth(float Lngth)
{
if((Wdth > 0.0) && (Wdth < 20.0))
float wdth = Wdth;
else
cout<<"Invalid Width."<<endl;
}
float Rectangle::getLngth(float Lngth)
{
return Lngth;
}
void Rectangle::setWdth(float Wdth)
{
if((Wdth > 0.0) && (Wdth < 20.0))
float wdth = Wdth;
else
cout<<"Invalid Width."<<endl;
}
float Rectangle::getWdth(float Wdth)
{
return Wdth;
}
void Rectangle::Perimeter(float lngth, float wdth)
{
cout<<"The Perimeter is "<<(2*(lngth + wdth));
}
void Rectangle::Area(float lngth, float wdth)
{
cout<<"The Area is "<<(lngth * wdth);
}
そして、これは私がエラーに遭遇し続ける場所です。コンパイラは、.cpp で行ったように、アンパサンドを追加してポインターを作成するように指示します。しかし、それはそれ自体で別のエラーを作成します。等々。何が間違っているのかわかりません。エラーは 10 行目と 11 行目で発生します。
#include <iostream>
using namespace std;
#include "RealRectangle.h"
int main()
{
Rectangle rectangle1();
Rectangle rectangle2();
cout<<rectangle1.Perimeter();
cout<<rectangle2.Area();
}