Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I just got the newer virsion of microsoft visual c++ 6.0 and now I am haveing problems with all of my functions. I wrote the simple function below to see what is going on. Even with it I get an error that says "C:\Program Files\Microsoft Visual Studio\MyProjects\test2\test2.cpp(10) : error C2447: missing function header (old-style formal list?)". Sorry if this is a dumb question but I haven't run into this error in the past and cant find info how to get rid of it.
#include <iostream>
void d();
void main()
{
d();
return;
}
void d();
{
cout << "HI";}

I can see one problem here. You have a semicolon on line 8 after your function name where you're trying to define it. Also you might want to add using namespace std; before your main() function.
- Rolos

1 - a definite problem is the semi-colon in your function declaration:
void d(); <--- should not be a ; here
{
..
}2 - I would expect your program to compile after fixing #1, but MSVC may be pickier about things than you are used to. So you may get warnings about not declaring parameters for your function.
#include <iostream>
void d(void);int main(int argc, char **argv)
{
d();
return 0;
}void d(void)
{
cout << "HI";
}
Putting void as the parameter in the prototype and the function declaration, tells the compiler that no parameters are allowed. This allows the compiler to check for you that function calls have the proper parameters and types. Note that when you call the function, you don't use the void. Declaring the function as d(), tells the compiler that you aren't telling it what parameters are required. When you do this, the compiler can't check parameters and types.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |