C++ enum Help!

ok so everything is good in my code but my ,Tirangles getShape(int s1, int s2, int s3) statement for my function it give me an error with Triangles

#include <iostream>
using namespace std;



enum Triangles { equilateral,isosceles,scalene};

void getSides(int &s1, int &s2, int &s3);
Tirangles getShape(int s1, int s2, int s3);

int main()
{
int s1,s2,s3;

getSides(s1,s2,s3);

system("pause");
return 0;
}

void getSides(int &s1, int &s2, int &s3)
{

cout << "Enter side 1 of your Triangle: ";
cin >> s1;

cout << "Enter side 2 of your Triangle: ";
cin >> s2;

cout << "Enter side 3 of your Triangle: ";
cin >> s3;
}



Tirangles getShape(int s1, int s2, int s3)
{
Triangles getShape;
if (s1+s2 <=s3 || s1+s3 <=s2 || s2+s3 <=s1)
{
cout<<"Not a valid Triangle"<< endl;;

}

else if (s1==s2 && s2==s3)
{
cout<<"You have a Equilateral Triangle"<< endl;;
}

else (s1==s2 || s1==s3 || s2==s1);
{
cout<<" You have a Isosceles triangle"<< endl;;
}

return getShape;

}
Last edited on
Double check your spelling of "Triangles" every time.

You also aren't setting the getShape instance equal to anything in your getShape function (equilateral,isosceles,scalene).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Triangles getShape(int s1, int s2, int s3) // Triangles spelt wrong
{
	Triangles getShape;
	if (s1+s2 <=s3 || s1+s3 <=s2 || s2+s3 <=s1)
	{
		cout<<"Not a valid Triangle"<< endl;
		getShape = scalene; // Or add a null Triangle enum
	}

	else if (s1==s2 && s2==s3)
	{
		cout<<"You have a Equilateral Triangle"<< endl;
		getShape = equilateral;
	}

	else (s1==s2 || s1==s3 || s2==s1);
	{
		cout<<" You have a Isosceles triangle"<< endl;
		getShape = isosceles;
	}

	return getShape; // You had forgotten to set getShape before returning it.
}
Topic archived. No new replies allowed.