[try Beta version]
Not logged in

 
Need Help with debugging

Oct 14, 2014 at 4:40pm
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 Oct 14, 2014 at 5:03pm
Oct 14, 2014 at 5:04pm
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)
Oct 14, 2014 at 5:05pm
You forgot to mention the return type when defining the function.
Oct 14, 2014 at 6:49pm
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.