I created a C++ Console Application in Visual Studio Community 2017. There is only a main.cpp file in the project. Here is my main.cpp file:
#include <iostream>
#include "stdafx.h"
int main()
{
std::cout << "hello world!";
return 0;
}
I get a compilation error that 'cout' is not a member of std. But if I include iostream after stdafx.h, that is,
#include "stdafx.h"
#include <iostream>
int main()
{
std::cout << "hello world!";
return 0;
}
then it compiles just fine. So why does it not work when I include iostream before stdafx.h?