Need Help with debugging

Hi! I have been doing c++ for 5 day and I have a problem I cant solve. So give it a go.

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
  #include <iostream>

using namespace std;

int AreaCube(int length, int width = 25, int height = 1);

int main() {

	int length = 100;
	int width = 50;
	int height = 2;
	int area;

	area = AreaCube(length, width, height);
	cout << "First area equals: " << area << "\n";

	area = AreaCube(length, width);
	cout << "Second time are equals: " << area << "\n";

	area = AreaCube(length);
	cout << "Third time area equals: " << area << "\n";

	return 0;
}

AreaCube(int length, int width, int height) {

	return (length * width * height);
}


My compiler(g++) say : DefaultParameterValues.cpp:28:43: error: ISO C++ forbids declaration of 'AreaCube' with no type [-fpermissive]
AreaCube(int length, int width, int height) {


Thanks
Last edited on
you are missing int on line 26 it should be

int AreaCube(int length, int width, int height)

instead of

AreaCube(int length, int width, int height)
You forgot to mention the return type when defining the function.
Thanks guys! Problem fixed. I guess it's a rookie mistake, but I am new to this and I am in am middle of learning functions so mistakes are expected. :)
Topic archived. No new replies allowed.