CString类中的函数

来源:百度知道 编辑:UC知道 时间:2024/05/31 05:23:58
VC控制台程序中要使用CString类中的函数,用这种方法:
project->setting->general 里的Microsoft Foundmation class选择“Use MFC in a Shared DLL”,再包含<afx.h>就行了。
调试显示WINDOWS.H already included. MFC apps must not #include <windows.h>
是什么原因???谢谢!
没有,我的程序的头文件是:#include <stdio.h>
#include <winsock.h>
#include <string.h>
#pragma comment(lib, "ws2_32.lib")
不知道是不是有冲突?
有什么问题??请教
谢谢master_fc,我一开始把#include <afx.h>放在所有声明的最后,按照你说的我把#include <afx.h>放在了最前面,结果就没有问题了。
但是我还想问一下,为什么会这样呢?声明的顺序有影响吗??谢谢!!
为什么有影响呢?

把#include <afx.h>放到"stdafx.h"后面,其他头文件的前面或者直接放到stdafx.h

#pragma comment(lib, "ws2_32.lib")
#include <WINSOCK2.H>
#include <stdio.h>
#include <string>

#include <afx.h>

的 前后位置是有关系的。这个应该是最开始的位置进行声明。

看看有没有StdAfx.h这个,有的话打开他删除里面的#include <windows.h>

你的头文件有问题