error C2447: '{' : missing function header (old-style formal list?)

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2008
Posts: 6
Reputation: noodlneck is an unknown quantity at this point 
Solved Threads: 0
noodlneck noodlneck is offline Offline
Newbie Poster

error C2447: '{' : missing function header (old-style formal list?)

 
0
  #1
Jan 24th, 2008
Hello

I'm haveing a problem running my program because i keep getting error C2447: '{' : missing function header (old-style formal list?). Can someone explain to me how to fix this problem? Below is a copy of my program. The program is designed to take three number inputed buy the user and determine which one is the highest.

  1. #include "stdafx.h"
  2. #include "conio.h"
  3. #include <iostream>
  4.  
  5.  
  6. using std::cout;
  7. using std::cin;
  8. using std::endl;
  9. using namespace std;
  10.  
  11. // function maximum definition;
  12. // x, y and z are parameters
  13.  
  14. float maximum(float x, float y, float z);
  15. {
  16. double x; // assume x is largest
  17. double y;
  18. double z;
  19.  
  20. if (x > y) && (x > Z)
  21. maximum = x
  22. else
  23. if (y > x) && (y > z)
  24. maximum = y
  25. else
  26. if (z > x) && (z > y)
  27. maximum = z
  28.  
  29. return maximum; // max is largest value
  30.  
  31. } // end function maximum
  32.  
  33. float maximum(float number1, float number2, float number3); // functional prototype
  34.  
  35. int main()
  36. {
  37. double number1;
  38. double number2;
  39. double number3;
  40. cout << "Enter three floating-point numbers: ";
  41. cin >> number1 >> number2 >> number3;
  42.  
  43. // number1, number2 and number3 are arguments to
  44. // the maximum function call
  45. cout << "Maximum is: " << number1 << number2 << number3 << endl;
  46.  
  47. return 0; // indicates successful termination
  48.  
  49.  
  50. } // end main
Last edited by Ancient Dragon; Jan 24th, 2008 at 6:39 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,741
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 281
Lerner Lerner is offline Offline
Posting Virtuoso

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #2
Jan 24th, 2008
>>float maximum(float x, float y, float z);

drop the semicolon at the end of this line.

With the function maximum() being defined before main() you don't need a function declaration as well. So you can delete the following line:
float maximum(float number1, float number2, float number3); // functional prototype
Last edited by Lerner; Jan 24th, 2008 at 5:36 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 6
Reputation: noodlneck is an unknown quantity at this point 
Solved Threads: 0
noodlneck noodlneck is offline Offline
Newbie Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #3
Jan 24th, 2008
Okay when i take the ( off the end of float maximun( float x, float y, float z) I get errors for the x,y,z variables and at the begining of the if then statement. However the function header error goes away. do Have any advice on that. I have listed the errors below.

error C2082: redefinition of formal parameter 'x'
error C2082: redefinition of formal parameter 'y'
error C2082: redefinition of formal parameter 'z'
error C2143: syntax error : missing ';' before '&&'
warning C4390: ';' : empty controlled statement found; is this the intent?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 35
Reputation: brk235 is an unknown quantity at this point 
Solved Threads: 1
brk235 brk235 is offline Offline
Light Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #4
Jan 24th, 2008
You need to remove re-definition of these variables agian here..remove these lines
double x; // assume x is largest
double y;
double z;
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 35
Reputation: brk235 is an unknown quantity at this point 
Solved Threads: 1
brk235 brk235 is offline Offline
Light Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #5
Jan 24th, 2008
you forgot call to the function from the main......
  1. int main()
  2. {
  3. double number1;
  4. double number2;
  5. double number3;
  6. double max;
  7. cout << "Enter three floating-point numbers: ";
  8. cin >> number1 >> number2 >> number3;
  9.  
  10. // number1, number2 and number3 are arguments to
  11. // the maximum function call
  12. max= maximum( x, y, z); //call to the function.....add this line here..
  13.  
  14.  
  15. cout << "Maximum is: " <<max<< endl;
  16.  
  17. return 0; // indicates successful termination
  18.  
  19.  
  20. } // end main
Last edited by Ancient Dragon; Jan 24th, 2008 at 6:41 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 6
Reputation: noodlneck is an unknown quantity at this point 
Solved Threads: 0
noodlneck noodlneck is offline Offline
Newbie Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #6
Jan 24th, 2008
But i still have the problem with the if then statment.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 35
Reputation: brk235 is an unknown quantity at this point 
Solved Threads: 1
brk235 brk235 is offline Offline
Light Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #7
Jan 24th, 2008
change ur if statements like this....

if( (x > y) && (x > Z) )
maximum = x;
else
if ((y > x) && (y > z))
maximum = y;
else
maximum = z;
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 6
Reputation: noodlneck is an unknown quantity at this point 
Solved Threads: 0
noodlneck noodlneck is offline Offline
Newbie Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #8
Jan 24th, 2008
Thanx for your help i really appreitiate it but i have one more error what does (error C2659: '=' : function as left operand) mean and how can i fix it. it shows up on the (write part of the if then statment)
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 35
Reputation: brk235 is an unknown quantity at this point 
Solved Threads: 1
brk235 brk235 is offline Offline
Light Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #9
Jan 24th, 2008
sorry..I couldn't get you...could you please tell me in which line you have error.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 6
Reputation: noodlneck is an unknown quantity at this point 
Solved Threads: 0
noodlneck noodlneck is offline Offline
Newbie Poster

Re: error C2447: '{' : missing function header (old-style formal list?)

 
0
  #10
Jan 24th, 2008
these are all the errors i am getting

if( (x > y) && (x > Z) )
maximum = x; (error C2659: '=' : function as left operand
else)
if ((y > x) && (y > z))
maximum = y; (error C2659: '=' : function as left operand)
else
maximum = z;(error C2659: '=' : function as left operand)
return maximum; // max is largest value(error C2440: 'return' : cannot convert from 'float (__cdecl *)(float,float,float)' to 'float')
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC