代码理解
IEC104NASlave.h主应用程序头文件
接上篇,中文注释即理解,已在前篇注释过的理解不再重新注释,有需要请翻看前面篇章。
C++代码审阅–ice104协议从站(1)
// IEC104NASlave.h : main header file for the IEC104NASLAVE application
//IEC104NASLAVE应用程序的主头文件
#if !defined(AFX_IEC104NASLAVE_H__3727DC37_9D6F_4120_B349_19C8571514A5__INCLUDED_)
#define AFX_IEC104NASLAVE_H__3727DC37_9D6F_4120_B349_19C8571514A5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#if !defined(_AFXDLL)
#define _AFXDLL
#endif //!defined(_AFXDLL)
/
// CIEC104NASlaveApp:
// See IEC104NASlave.cpp for the implementation of this class
//
class CIEC104NASlaveApp : public CWinApp //定义基类CIEC104NASlaveApp,派生类CWinApp,继承公有成员
{
public:
CIEC104NASlaveApp(); //这就是公有成员,成员有public(公有成员),private(私有成员),prctected(受保护成员)三种,默认private。
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIEC104NASlaveApp)
public:
virtual BOOL InitInstance();//这也是公有成员,允许有多个public,编译效果是一样的,virtual定义一个布尔类型的虚函数(理解跟多态有关,先不管)
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CIEC104NASlaveApp)
// 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()
/*
DECLARE_MESSAGE_MAP()宏作用是向类中添加消息映射必要的结构体和函数声明,
在实现了类函数.cpp文件中加入BEGIN_MESSAGE_MAP,再加入每个消息处理函数的宏入口,在用END_MESSAGE_MAP结束
*/
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IEC104NASLAVE_H__3727DC37_9D6F_4120_B349_19C8571514A5__INCLUDED_)
文件含义
IEC104NASLAVE应用程序的主头文件,定义了一个CIEC104NASlaveApp基类和 CWinApp派生类
该类有两个共有成员,一个是CIEC104NASlaveApp()以及InitInstance(),最后声明了一个DECLARE_MESSAGE_MAP()宏。
涉及基础知识
1.include和define:https://blog.csdn.net/helenchen1995/article/details/100031072
2.头文件和源文件C++中的 .h 和 .cpp 详解
3.条件编译https://blog.csdn.net/qq_36662437/article/details/81476572
4.类和对象https://www.runoob.com/cplusplus/cpp-classes-objects.html
5.类和对象访问修饰符https://www.runoob.com/cplusplus/cpp-class-access-modifiers.html
6.注释https://www.runoob.com/cplusplus/cpp-comments.html
7.宏定义https://blog.csdn.net/u012308586/article/details/90407932
8.MFChttps://baike.baidu.com/item/MFC/2530850?fr=aladdin
9.继承https://www.runoob.com/cplusplus/cpp-inheritance.html