error C1010: unexpected end of file while looking for precompiled header.

Hello!I tried out a program on constructors in VC++ 2008 Express Edition and Turbo C++.On compilation both of them showed 0 errors and 0 warnings.But while running the program VC++ showed:
"fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?" and failed to run.But Turbo C++ ran the program smoothly and showed the output. Could any one tell me what's the reason behind and how to fix the problem?
My code in VC++:

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
30
31
32
#include"stdafx.h"
#include <iostream>
using namespace std;

class integer
{
	int m,n;
public:
	integer(int,int);
	void disp(void)
	{
		cout<<m<<" "<<n;
	}
};
integer::integer(int x, int y)
{
	m=x;
	n=y;
}
int main()
{
integer int1(0,100);

integer int2=integer(25,75);
cout<<"\nOBJECT1"<<endl;
int1.disp();

cout<<"\nOBJECT2"<<endl;
int2.disp();

return 0;
}
Disable the precompiled header option in Project Options.
I disabled the precompiled header option and then tried to run the program.But I got the following errors:
1."stdafx.obj : error LNK2005: "public: __thiscall integer::integer(int,int)" (??0integer@@QAE@HH@Z) already defined in constructor.obj"
2."stdafx.obj : error LNK2005: _main already defined in constructor.obj"
3."C:\Documents and Settings\Dr. D.K.Kundu\My Documents\Visual Studio 2008\Projects\constructor\Debug\constructor.exe : fatal error LNK1169: one or more multiply defined symbols found"
Sigh.....................
Copy the code somewhere and recreate the project. This time make sure you make it an empty Win32 console program. You'll have to add the .cpp yourself.

EDIT: Oh, wait. First try deleting all files in the project except the one that contains main(). Don't forget to remove the include.
Last edited on
Oh! Thanks a lot! It worked!!!
Topic archived. No new replies allowed.