Help with Class member function

I'm suppose to create a program with a class with four members function to calculate the area of a triangle, square, hexagon, octagon with you enter the length of the side.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  #include <iostream>
using namespace std;

class Area
{

private:
	
	double L;

public: 

	Area(double L);
 void SideLength();
 void CalcAreaTriangle();
 void CalcAreaSquare();
 void CalcAreaHexagon();
 void CalcAreaOctagon();

};

void Area::SideLength()
{
cout << "Enter the length of the side";
cin >> L;
}
void Area::CalcAreaTriangle()
{
cout << 0.433013*L*L;
}
void Area::CalcAreaSquare()
{
cout << L*L;
}
 void Area::CalcAreaHexagon()
{
cout << 2.59808*L*L;
}
 void Area::CalcAreaOctagon()
{
cout << 4.82843*L*L;
}

int main ()
{
	double L;
Area CalcAreaTriangle(L);
Area CalcAreaSquare(L);
Area CalcAreaHexagon(L);
Area CalcAreaOctagon(L);
	
	
	
	
	cout << "Area Trinagle = "; 
	CalcAreaTriangle(L);
	cout << "Area Square = ";
	CalcAreaSquare(L);
	cout << "Area Hexagon = "; 
	CalcAreaHexagon(L);
	cout << "Area Octagon = "; 
	CalcAreaOctagon(L);
	cout << endl;
	

system ("pause");
return 0;
}

Last edited on
Topic archived. No new replies allowed.