Question : Why is #include "stdafx.h" required to run the following code from this C++ book?

I am running Visual C++ 2008 Express and I'm curious to know why #include "stdafx.h" is required to run the following code from my "Accelerated C++: Practical Programming by Example" book:


// a small C++ program
#include

int main()
{
      std::cout << "Hello, world!" << std::endl;
      return 0;
}


The program fails if I remove #include "stdafx.h" from it. Also, Is there anything else I need to watch out for when compiling the code from this year 2000 book in my Visual C++ 2008 Express environment? Are there any other #include statements you can think of that I might need down the road, that won't be mentioned in the book, in order to get it working in Visual C++ 2008?

Answer : Why is #include "stdafx.h" required to run the following code from this C++ book?

Further info.
Using precompiled headers option - that speeds up the compile/build process by only compiling changed files, the stdafx.h is required as part of the process.
For a small app like this it won't make that much of a difference.  For larger apps it could reduce the time taken by many minutes.  I would keep the option enabled.
Random Solutions  
 
programming4us programming4us