I have this extremely simple main function
#include "stdafx.h"
#include "abc.h"
int _tmain(int argc, _TCHAR* argv[])
{
abc obj;
obj.show();
return 0;
}
Everything is compiling normally...but when i am writing
#include "abc.h"
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
abc obj;
obj.show();
return 0;
}
The compiler is going haywire..
error C2065: 'abc' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'obj'
error C2065: 'obj' : undeclared identifier
error C2228: left of '.show' must have class/struct/union
type is ''unknown-type''
Why is it mandatory to include
stdafx.h
at the start? I am new in C++ ...maybe I am making a silly mistake. Please help :(
(Using: VS2005 with C++ 98)
stdafx.h
directy in yourabc.h
if you requires declarations from it. At least, if the include order matters, it's a sign there is something wrong with the content of the.h
files themselves. – Bregaladstdafx.h
is related to precompiled headers mechanism in VS. It has to be 1st ... because it has (it uses precompiler magic) =). It's not a dependency. One read, second read. – luk32