ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:1.45MB ,
资源ID:16567331      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/16567331.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(VC++66教材Word文档格式.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

VC++66教材Word文档格式.docx

1、C中调用C+中的代码这样定义会是安全的。一般的考虑跨平台使用方法如下:#ifdefined(_cplusplus)|defined(c_plusplus) /跨平台定义方法extern #endif/. 正常的声明段#ifdefined(_cplusplus)|defined(c_plusplus)#endif 简单的用在windows下可以如下定义:#ifdef _cplusplusextern /. 正常的声明段#endiftypedef int LONG32, *PLONG32;typedef int INT32, *PINT32;这跟宏定义差不多,学名是“类型定义”。C+为了跟C区别就

2、定义了很多这类大写的类型名LONG UINT INT等等。当然同时支持C的小写类型名。Int long等。例如:typedef unsigned int ULONG32, *PULONG32;typedef unsigned int DWORD32, *PDWORD32;typedef unsigned int UINT32, *PUINT32;另:对于32,64位数据类型,目前多数是32位使用的比较多。64位基本上没有。因为32位基本上满足了我们的需求。64位的宏开关是这样写的:#ifdef _WIN64 typedef _int64 INT_PTR, *PINT_PTR;typedef u

3、nsigned _int64 UINT_PTR, *PUINT_PTR;指针类型和整形类型之间的转换函数定义:_inlineunsigned longHandleToUlong( void *h ) return(unsigned long) h );PtrToUlong( void *p return(unsigned long) p );unsigned shortPtrToUshort( return(unsigned short) p );longPtrToLong( return(long) p );shortPtrToShort( return(short) p );#endif#

4、pragma warning(3:4311) / type cast truncation#elsetypedef long INT_PTR, *PINT_PTR;typedef unsigned long UINT_PTR, *PUINT_PTR;#define MAXINT_PTR (0x7fffffffL) 指针类型的数据最大值#define MININT_PTR (0x80000000L) 指针类型的数据最小值#define MAXUINT_PTR (0xffffffffUL) 指针类型的数据最大值typedef unsigned short UHALF_PTR, *PUHALF_PT

5、R; short短无符号整形定义的短指针类型(小指针)typedef short HALF_PTR, *PHALF_PTR;short短有符号整形定义的短指针类型(小指针)#define MAXUHALF_PTR 0xffff 短指针类型的最大值#define MAXHALF_PTR 0x7fff 短指针类型的最大值#define MINHALF_PTR 0x8000 短指针类型的最小值/函数形式的宏定义#define HandleToUlong( h ) (ULONG) (h) ) #define PtrToUlong( p ) (ULONG) (p) )#define PtrToLong(

6、 p ) (LONG) (p) )#define PtrToUshort( p ) (unsigned short) (p) )#define PtrToShort( p ) (short) (p) )inline 的函数必须和函数定义一起用才起作用, 而且调用方必须能够看到这个函数的定义, 如:/ a.hinline void foo(void);/ a.cinline void foo(void)/ b.c#include a.hvoid bar(void)foo();这种用法 inline 是不起任何作用的, 只有这样:这样才能真正的内联; 内联是在编译期间处理的, 第一种情况, 如果编

7、译器编译 b.c 的时候, 只看到 foo 的声明, 而看不到其定义, 编译器就没办法把 foo 函数内联到调用处!所谓的内联就是把函数里面的代码直接拷贝到执行的代码里面再编译,而不是按着函数实现体来编译。(以上是basetsd.h文件。Stdafx.h文件是用来包含标准头文件的,一般C+的函数找不到时就是因为头文件没有包含进来。)总结:宏定义本身其实就是替换掉代码里的宏名为定义体。只是置换的作用。函数形式的宏定义用来实现复杂的一些代码形式。比如参数类型的互换,C+重载功能的宏实现等。 VC+教材第二课MFC类库介绍CWinApp类:应用程序入口类,一般从这里开始执行代码。先简单介绍一下C+类

8、头文件H和实现体文件CPP基本结构。1,头文件里有针对类的宏定义/ test.h : main header file for the TEST application/#if !defined(AFX_TEST_H_67369212_1733_4E81_8D0C_4EB216B09392_INCLUDED_)#define AFX_TEST_H_67369212_1733_4E81_8D0C_4EB216B09392_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER #ifndef _AFXWIN_H_ #error includ

9、e stdafx.h before including this file for PCHresource.h / main symbols/ CTestApp:/ See test.cpp for the implementation of this classclass CTestApp : public CWinApppublic: CTestApp();/ Overrides / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CTestApp) public: virtual BOOL InitInstanc

10、e(); /AFX_VIRTUAL/ Implementation /AFX_MSG(CTestApp) / NOTE - the ClassWizard will add and remove member functions here. / DO NOT EDIT what you see in these blocks of generated code ! /AFX_MSG DECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immedia

11、tely before the previous line.#endif / !2,实现体文件/ test.cpp : Defines the class behaviors for the application.stdafx.htest.htestDlg.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;/ CTestAppBEGIN_MESSAGE_MAP(CTestApp, CWinApp) /AFX_MSG_MAP(CTestApp) / NOTE - the Class

12、Wizard will add and remove mapping macros here. / DO NOT EDIT what you see in these blocks of generated code! ON_COMMAND(ID_HELP, CWinApp:OnHelp)END_MESSAGE_MAP()/ CTestApp constructionCTestApp:CTestApp() / TODO: add construction code here, / Place all significant initialization in InitInstance/ The

13、 one and only CTestApp objectCTestApp theApp;/ CTestApp initializationBOOL CTestApp:InitInstance() if (!AfxSocketInit() AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; AfxEnableControlContainer(); / Standard initialization / If you are not using these features and wish to reduce the size / of

14、your final executable, you should remove from the following / the specific initialization routines you do not need.#ifdef _AFXDLL Enable3dControls(); / Call this when using MFC in a shared DLL Enable3dControlsStatic(); / Call this when linking to MFC statically CTestDlg dlg; m_pMainWnd = &dlg; int n

15、Response = dlg.DoModal(); if (nResponse = IDOK) / TODO: Place code here to handle when the dialog is / dismissed with OK else if (nResponse = IDCANCEL) / dismissed with Cancel / Since the dialog has been closed, return FALSE so that we exit the / application, rather than start the applications messa

16、ge pump. return FALSE;3,CWinApp的InitInstance函数:应用程序的事例初始化函数,包括初始化代码和初期窗口显示代码。/建立模式对话框这是对话框模式的代码。 CSingleDocTemplate* pDocTemplate;/文档模版的创建 pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CViewDoc), RUNTIME_CLASS(CMainFrame), / main SDI frame window RUNTIME_CLASS(CViewView); AddDo

17、cTemplate(pDocTemplate);/解析SHELL命令行 / Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo);/执行SHELL命令行 / Dispatch commands specified on the command lineProcessShellCommand(cmdInfo)/显示窗口 / The one and only window has been initialized, so show and update it. m_pMainWnd-ShowWindow(SW_SHOW);UpdateWindow();这是文档模式的代码。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1