Can someone help me please? I've got 17 errors and 3 warnings. The main problem is that it keeps telling me that "Triangle" isn't a class name :confused: i'm so confused. Could you also help me with any other problems that you see? Thx in advance. (list of errors at bottom)
#include <iostream.h>
class Triangle
{
public:
friend Triangle Copy(Triangle triangle1);
friend bool operator ==(const Triangle& triangle1, const Triangle& triangle2);
friend ostream& operator <<(ostream& outs, Triangle& the_triangle);
Triangle(float side1, float side2, float side3);
Triangle();
void SetTriangle(float side1, float side2, float side3);
bool IsEquilateral();
bool IsIsosceles();
bool IsScalene();
bool IsRight();
bool IsAcute();
bool IsObtuse();
float get_side1();
float get_side2();
float get_side3();
private:
void swap(float& side_1, float& side_2);
void order();
float side_1, side_2, side_3;
};
void main()
{
Triangle triangle1, triangle2(6.0, 6.0, 6.0), triangle3(5.0, 4.0, 3.0), triangle4(6.0, 4.0. 4.0);
cout << "display triangle 2: \n";
}
Triangle::Triangle(float side1, float side2, float side3)
{
SetTriangle(side1, side2, side3);
order();
}
Triangle::Triangle()
{
side_1 = 0;
side_2 = 0;
side_3 = 0;
}
void Triangle::SetTriangle(float side1, float side2, float side3)
{
side_1 = side1;
side_2 = side2;
side_3 = side3;
order ();
}
void Triangle::swap(float& side_1, float& side_2)
{
float temp = side_1;
side_1 = side_2;
side_2 = temp;
}
void Triangle::order()
{
if (side_1 > side_2)
swap (side_1, side_2);
if (side_1 > side_3)
swap (side_1, side_3);
if (side_2 > side_3)
swap (side_2, side_3);
}
float Triangle::get_side1()
{
return side_1;
}
float Triangle::get_side2()
{
return side_2;
}
float Triangle::get_side3()
{
return side_3;
}
Triangle
friend bool operator ==(const Triangle& Triangle1, const Triangle& Triangle2)
{
return((Triangle1.get_side1() == Triangle2.get_side1()) && (Triangle1.get_side2() == Triangle2.get_side2()) && (Triangle1.get_side3() == Triangle2.get_side3()));
}
Triangle
friend Triangle::ostream& operator <<(ostream& outs, Triangle& the_triangle)
{
return(outs << the_triangle.get_side1() << the_triangle.get_side2() << the_triangle.get_side3());
}
bool Triangle::IsEquilateral()
{
return((side_1 == side_2) && (side_2 == side_3));
}
bool Triangle::IsIsosceles()
{
if ((side_1 == side_2) && (side_2 == side_3))
return(false);
if((side_1 == side_2) && (side_1 != side_3) && (side_2 != side_3))
return(true);
if((side_2 == side_3) && (side_2 != side_1) && (side_3 != side_1))
return(true);
if((side_1 == side_3) && (side_1 != side_2) && (side_3 != side_2))
return(true);
}
bool Triangle::IsScalene()
{
return(side_1 != side_2 && side_2 != side_3 && side_1 != side_3);
}
bool Triangle::IsRight()
{
return(side_3 * side_3 == side_1 * side_1 + side_2 * side_2);
}
bool Triangle::IsAcute()
{
return(side_1 + side_2 < side_3);
}
bool Triangle::IsObtuse()
{
return (side_3 * side_3 > side_1 * side_1 + side_2 * side_2);
}
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(36) : error C2059: syntax error : 'constant'
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(37) : error C2228: left of '.cout' must have class/struct/union type
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(37) : error C2297: '<<' : illegal, right operand has type 'char [22]'
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(41) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(45) : warning C4508: 'Triangle' : function should return a value; 'void' return type assumed
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(47) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(52) : warning C4508: 'Triangle' : function should return a value; 'void' return type assumed
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(54) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(55) : error C2373: 'SetTriangle' : redefinition; different type modifiers
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(62) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(64) : warning C4244: 'initializing' : conversion from 'int' to 'float', possible loss of data
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(69) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(70) : error C2373: 'order' : redefinition; different type modifiers
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(79) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(83) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(87) : error C2653: 'Triangle' : is not a class or namespace name
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(93) : error C2144: syntax error : missing ';' before type 'int'
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(93) : error C2501: 'Triangle' : missing storage-class or type specifiers
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(93) : error C2373: 'Triangle' : redefinition; different type modifiers
C:\Documents and Settings\owner\My Documents\C++\lab7\lab7.cpp(93) : fatal error C1004: unexpected end of file found