#include iostream before stdafx.h in c++

前端 未结 1 511
感动是毒
感动是毒 2021-01-29 10:54

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 

        
相关标签:
1条回答
  • 2021-01-29 11:20

    The answer to your question can be found, with a little puzzling, here.

    stdafx.h enables precompiled headers. Based on the error given, and the discussion of how Microsoft implements precompiled headers, it seems that the compiler simply starts compiling from the include of stdafx.h forward. So when stdafx.h is placed after iostream, iostream is not included, producing the mysterious error.

    0 讨论(0)
提交回复
热议问题