| | |
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:
Solved Threads: 0
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.
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.
c++ Syntax (Toggle Plain Text)
#include "stdafx.h" #include "conio.h" #include <iostream> using std::cout; using std::cin; using std::endl; using namespace std; // function maximum definition; // x, y and z are parameters float maximum(float x, float y, float z); { double x; // assume x is largest double y; double z; if (x > y) && (x > Z) maximum = x else if (y > x) && (y > z) maximum = y else if (z > x) && (z > y) maximum = z return maximum; // max is largest value } // end function maximum float maximum(float number1, float number2, float number3); // functional prototype int main() { double number1; double number2; double number3; cout << "Enter three floating-point numbers: "; cin >> number1 >> number2 >> number3; // number1, number2 and number3 are arguments to // the maximum function call cout << "Maximum is: " << number1 << number2 << number3 << endl; return 0; // indicates successful termination } // end main
Last edited by Ancient Dragon; Jan 24th, 2008 at 6:39 pm. Reason: add code tags
•
•
Join Date: Jul 2005
Posts: 1,741
Reputation:
Solved Threads: 281
>>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
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.
•
•
Join Date: Jan 2008
Posts: 6
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Nov 2007
Posts: 35
Reputation:
Solved Threads: 1
you forgot call to the function from the main......
c++ Syntax (Toggle Plain Text)
int main() { double number1; double number2; double number3; double max; cout << "Enter three floating-point numbers: "; cin >> number1 >> number2 >> number3; // number1, number2 and number3 are arguments to // the maximum function call max= maximum( x, y, z); //call to the function.....add this line here.. cout << "Maximum is: " <<max<< endl; return 0; // indicates successful termination } // end main
Last edited by Ancient Dragon; Jan 24th, 2008 at 6:41 pm. Reason: add code tags
•
•
Join Date: Jan 2008
Posts: 6
Reputation:
Solved Threads: 0
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')
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')
![]() |
Similar Threads
- error C2447: '{' : missing function header (old-style formal list?) (C++)
- Wierd error messages with calculator program (C++)
- error C2447: missing function header (old-style formal list?), what does this mean?! (C++)
Other Threads in the C++ Forum
- Previous Thread: Downloadable video lectures on C and C++
- Next Thread: Crossing fingers* Outputting to an outlook email
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






