Try declaring the second overloaded function at the start of the program.
>From: "Blagger" <car...@sk...>
>To: <dev...@li...>
>Subject: [Dev-C++] Begginer's question, Function overloading
>Date: Sat, 18 Apr 2015 20:06:14 +0200
>
>Hi
>
>As a beginner I came to the chapter "function overloading" of a C++
>handbook
>and had the following exercise.
>The problem with this listing is that dev-C++ gives me the errors :
>110 too many arguments to function double f-seize(double,double)
>320 at this point in line.
>
>I know this, that's why it's called function overloading, or am I
>completely
>wrong ?
>Thanks in advance for any help.
>
>10 // computing clothes size
>20 // excercise on functions with function overloading
>30
>40 #include <stdio.h>
>50 #include <iostream.h>
>60 #include <conio.h>
>70 #include <math.h>
>80
>90 double hat_seize(double h_weight,double h_height);
>100 // first function returns hat-seize
>110 double f_seize(double j_weight,double j_years);
>120 // second function returns Waist in inches
>130 // when overloaded and returns also Jacket seize
>140
>150 int main(int argc, char *argv[])
>160 {
>170 cout.setf(ios::fixed);
>180 cout.setf(ios::showpoint);
>190 cout.precision(1);
>200 char answer = 'y';
>210 double height, weight, age, h_seize,j_seize,w_seize;
>220
>230 do
>240 {
>250 cout << "\nTyp hier uw lengte in (in cm) : "; cin >> height;
>260 cout << "\nTyp hier uw gewicht in (in kg) : "; cin >> weight;
>270 cout << "\nTyp hier uw leeftijd in (jaren) : "; cin >> age;
>280 cout << "\nEffe wachtte" << endl;
>290 h_seize = hat_seize(weight,height);
>300 w_seize = f_seize(weight,age);
>310 // now we overload the second function :
>320 j_seize = f_seize(weight,height,age);
>330 cout << "\n De grootte van uw hoed : "; cin >> h_seize;
>340 cout << "\n De grootte van uw jas : "; cin >> j_seize;
>350 cout << "\n De grootte van uw broek : "; cin >> w_seize; cout <<
>endl;
>360 cout << "\n\tNogmaals? (Y/N) : "; cin >> answer;
>370
>380 }
>390 while ((answer == 'Y') || (answer == 'y'));
>400
>410 getch();
>420
>430 return 0;
>440 }
>450
>460 // first function calculates hat-size
>470 double hat_seize(double h_weight,double h_height)
>480 {
>490 return ((h_weight / h_height) * 2.9);
>500 }
>510
>520 //Second function (normal)
>530 double f_seize(double j_weight,double j_years)
>540 {
>550 return ((j_weight/5.7) + (floor((j_years - 28)/2)/10));
>560 }
>570 //Second function (overloaded)
>580 double f_seize(double j_weight,double j_height, double j_years)
>590 {
>600 return (((j_weight * j_height)/288) + (floor((j_years - 30)/10)/8));
>610 }
>
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
|