Very Frustrated, please help

I have tried everything I know, (which isn't much at all), and I cannot seem to get this program to run properly. I am down to one error, (I think), and cannot seem to get passed it.

error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')

It fails on line 44 of the main.cpp
cout<< "Area of the square is "<square.getArea;


main.cpp

#include <iostream>
#include "Circle.cpp"
#include "Circle.h"
#include "Square.cpp"
#include "Square.h"

using namesspace std;

int main()
{
int radius;
int length;
Square square;
Circle circle;
int menuOption;
do

{
cout <<end1 << " Calculate Area " <<end1;
cout << "Select an Object" << end1;
cout << " 1: Circle" <<end1;
cout << " 2: Square" <<end1;
cout << " 0: Exit" <<end1;
cout << " Enter your choice";
cin >> menuOption;

switch(menuOption)
{

case 1:

{
cout<< "Enter radius :"<<end1;
cin>> radius;
cout<< "Area of the circle is "<<circle.getArea();
break;
}

case 2

{
cout<< "Enter the length of one side of the square :"<<end1;
cin>> length;
cout<< "Area of the square is "<<square.getArea;
}
}
}

while(menuOption!=0);

cout<< "Have a great day "<<end1;
}



circle.cpp

#include "Circle.h"
#include <iostream>

using namespace std;

Circle::Circle (int r)
{
radius =r;
}

int Circle::getRadius()const
{
return radius;
}

double Circle::getArea()const
{
return radius * 3.141592653589793;
}



circle.h

#ifndef CIRCLE_H_INCLUDED
#define CIRCLE_H_INCLUDED
#include <iostream>

using namespace std;

circle Circle
{
public:
Circle (int radius);
int getRadius()const;
void setRadius(int radius);
double getArea()const

private:
int radius;
}
#endif //CIRCLE_H_INCLUDED



square.cpp

#include "Square.h"
#include <iostream>

using namespace std;

Square::Square (int len)
{
length = len;
}
int Square::getLength()const
{
return length;
}
int Square::getArea()const
{
return length * length;
}



square.h

#ifndef SQUARE_H
#define SQUARE_H
#include <iostream>

using namespace std;

//variables can be initialized during dictation

class Square
{
public:
Square (int length =0);
int getLength()cont;
void setLength(int length);
int getArea()const;

private:
int length;

};
#endif //SQUARE_H


Thank you for any assistance!!
Last edited on
It seems you forgot the parentheses.
 
cout<< "Area of the square is "<<square.getArea();
Thank you for the reply, once I add the () I get the following:
undefined reference to 'Square::Square(int)'
undefined reference to 'Circle::Circle(int)'
undefined reference to 'Circle::setRadiuse(int)'
undefined reference to 'Circle::getArea() const'
undefined reference to 'Square::setLength(int)'
undefined reference to 'Square::getArea() const'

UGH!
ok, after removing a few lines, it actually built but is not displaying any results. I have adjusted the main code to reflect what I have changed. I am almost there, I think.....
The program actually builds, but after entering data the result is always a 0. Any one have any ideas? Thank you!
looks like local vs class variables?

i see radius * Radius (what is Radius? why do you have 2 versions of it?)

it looks to me for example that if they pick circle, you read the local to main radius, then call the computation function which uses circle's radius, which is defaulted to zero and NOT THE SAME AS WHAT IS IN MAIN. You need to SET the class member radius to what was entered.

As a side not I strongly advise you to never have extremely similar or identical variable names. It just causes problems. Even if you have to type "mainsradius" in main.
Thank you jonnin, I have removed the =0 and the extra radius in radius * radius * 3.14....

Still getting a return of 0.....I've adjusted the initial code to reflect what I have now

Thank you for the help!
did you set the class variable to the input value?

Topic archived. No new replies allowed.