读书人

头文件放置还有顺序有关问题吗

发布时间: 2012-04-05 12:42:39 作者: rapoo

头文件放置还有顺序问题吗?
在VC6.0建一个控制台工程,
当这样是:
#include <math.h>
#include "stdafx.h "
#include <iostream>
using namespace std;

出现一个错误:
error C2065: 'sqrt ' : undeclared identifier

改为
#include "stdafx.h "
#include <iostream>
using namespace std;
#include <math.h>

重新编译后,一个错误也没有了。头文件放置还有顺序问题吗?

[解决办法]
#include "stdafx.h "要写在前面
[解决办法]
#include "stdafx.h " 使用预编译头文件需要把它放到程序最前面,否则它前面的内容会被忽略。

读书人网 >C++

热点推荐