0

Hello,

main.cpp

```
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include "Triangle.h"
using namespace std;
int main()
{
Triangle myTriangle;
int side1;
double side2;
double side3;
string input;
char ch;
do
{
cout << "Triangle ADT Program" << endl;
cout << "Enter the side lengths :" << endl;
cout << "---------------------" << endl;
cout << "Enter length 1> ";
getline(cin, input);
side1 = myTriangle.setside1(side1);
cout << "Enter length 2> ";
getline(cin, input);
side2 = myTriangle.setside2(side2);
cout << "Enter length 3> ";
getline(cin, input);
side3 = myTriangle.setside3(side3);
cout << "---------------------" << endl;
cout << "This triangle is a "; myTriangle.getTriangle(); cout << endl;
cout << "The area of the triangle is "; myTriangle.getArea(); cout << endl;
cout << "Would you like to modify any of the lengths? y/n ";
cin >> ch;
}while(ch == 'y' || ch == 'Y');
return 0;
}
```

Tringle.cpp

```
#include <iostream>
#include "Triangle.h"
#include
using namespace std;
Triangle::Triangle() : side1(0),side2(0),side3(0)
{
}
Triangle::Triangle(double a, double b, double c)
{
side1 = a;
side2 = b;
side3 = c;
}
void Triangle::setside1(double newside1)
{
*side1 = newside1;
}
double Triangle::getside1()
{
return side1;
}
void Triangle::setside2(double newside2)
{
side2 = newside2;
}
double Triangle::getside2()
{
return side2;
}
void Triangle::setside3(double newside3)
{
side3 = newside3;
}
double Triangle::getside3()
{
return side3;
}
double Triangle::getArea()
{
double s;
s = ( side1 + side2 + side3 ) / 2;
return sqrt( s * ( s - side1 ) * ( s - side2 ) * ( s - side3));
}
void Triangle::getTriangle()
{
if( ( side1 * side1 ) + ( side3 * side3 ) == ( side2 * side2 ) )
{
cout << "right triangle";
}else if( side1 == side2 && side2 == side3 )
{
cout << "equilateral triangle";
}else if( side1 == side2 || side2 == side3 || side1 == side3 )
{
cout << "isosceles triangle";
}
}
```

Tringle.h

```
#ifndef TRIANGLE_H
#define TRIANGLE_H
class Triangle
{
public:
Triangle();
Triangle(double a, double b, double );
void setside1(double newLength1);
double getside1() const;
void setside2(double newLength2);
double getside2() const;
void setside3(double newLength3);
double getside3() const;
double getArea() const;
void getTriangle() const;
private:
double side1;
double side2;
double side3;
};
#endif
```

-------------------------

Error

```
main.cpp:26:10: error: assigning to 'int' from incompatible type 'void'
side1 = myTriangle.setside1(side1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:30:10: error: assigning to 'double' from incompatible type 'void'
side2 = myTriangle.setside2(side2);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:34:10: error: assigning to 'double' from incompatible type 'void'
side3 = myTriangle.setside3(side3);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
```

--------------------

Do you know what's wrong with this code and how to fix it ?