Function Overloading

I keep getting the error ") expected".
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
 #include<iostream.h>
#include<math.h>
float area(float x)
{
	float z;
	z=3.14*x*x;
	return z;
}
float area(float x, y)
{
	float z;
	z=3.14*x(x+sqrt(x*x+y*y));
	//'x' is radius and 'y' is height.
	return z;
}
int area(int x)
{
	float z;
	z=pow(x,2.0);
	return z;
}
void main()
{
	float area(float);
	float area(float, float);
	int area(int);
	float z, y, x, p, q;
	int a,b;
	cout<<"Enter radius of circle=";
	cin>>z;
	p=area(z);
	cout<<"Area is="<<p;
	cout<<"\nEnter radius of cone=";
	cin>>x;
	cout<<"Enter height of cone=";
	cin>>y;
	q=area(x, y);
	cout<<"Area of cone is="<<q;
	cout<<"\nEnter side of square=";
	cin>>a;
	b=area(a);
	cout<<"Area of square is="<<b;
}
main should be int main() rather than void, void is not standard and not supported by all compilers.

edit: also this isnt valid:

z=3.14*x(x+sqrt(x*x+y*y));

it would need to be

z=3.14*x*(x+sqrt(x*x+y*y));
Last edited on
Thanks a lot Ashely Brown.
Topic archived. No new replies allowed.