c++多了个包含文件就错误

来源:百度知道 编辑:UC知道 时间:2024/06/09 10:09:05
#include "windows.h"
#include "string"
using namespace std;
void main()
{
string b;
int p;
}
------------上面这段代码是错误的
下面这段才是正确的
#include "string"
using namespace std;
void main()
{
string b;
int p;
}
---------就少了第一句,为什么我多写那句就会出现错误呢?
我又没有用到它。。。
warning C4101: 'p' : unreferenced local variable

我在vs7.1上是对的!

如果错了,请把编译器报的错贴出来!

或者使用:
#include <Windows.h>
#include <string>
试一下!

///
warning C4101: 'p' : unreferenced local variable

这是编译器给出的警告, 没有使用的局部变量 p;
程序并没有错误!

我的编译器没出错,看来是你的windos.h头文件丢失了或文件格式出问题了,重新替换include文件夹,再试试。

你用的什么编译器,我在VC6.0下是正确的,可能你 的编译器里windos.h被破坏了

一个可能是你库文件里面没有String这个文件,另一个可能是你在String文件里面有跟windows.h重复定义的问题。但具体是什么还需要你把错误提示贴出来才好确定

你都知道是#include "windows.h" 有问题。
那就从这查啊,看报什么错误。
可能你的编译器里windos.h有问题了。
我VC6是可以成功的。

没有用到它当然不会错,这里关键是看错误的提示是什么,你怎么不贴出来?是找不到这个windows.h文件还是别的什么?
凭空问谁会知道呢?