So I'm studying about class/objects and decided to make a simple program, but it's not working.
#include <iostream>
using namespace std;
Class Square
{
private:
double width;
double length;
public:
void setWidth(double wid)
{width = wid;}
void setLength(double len)
{length = len;}
double getWidth()
{return width;}
double getLength()
{return length;}
double getArea()
{return width * length;}
};
int main()
{
Square square1;
double recwidth;
double reclength;
cout << "Enter width of square: "<<endl;
cin >> recwidth;
cout << "Enter length of square: "<<endl;
cin >> reclength;
square1.setWidth(recwidth);
square1.setLength(reclength);
cout << "The area of the square is: " << square1.getArea() << endl;
}
shouldn't it be that your complain is it won't compile?
hint: Class Square
Haha, thank you, really stupid mistake. Also forgot to add return 0; at the end.