2022年学习笔记2.pdf





《2022年学习笔记2.pdf》由会员分享,可在线阅读,更多相关《2022年学习笔记2.pdf(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、孙鑫 vc+学习笔记( Sun Xin vc+ learning notes)1. about creating window applications Understand the capabilities of the windows program, the API function, the relationship between the message queue and the operating system, the input and output devices Window programming, sub background and front desk Front
2、 desk for what kind of window, how to display the title, and the destruction of the window, the day after tomorrow continue to run Background is the design purpose, he is through the window message queue continuous access to messages (GetMessage and translation), that is, the winprocess function of
3、the sub function to call (callback function) to achieve, written by the user himself Messages are implemented through applications that provide functions to the system platform to tune the effects of hardware, sound, or images. Applications are built on application systems The concrete steps are as
4、follows The construction of new Win32 Application source program written in empty project file with C program source file that contains the windows.h file to the WinMain function to write it contains the main function of this program with the function of DOS under the same entrance when the applicat
5、ion ends its WinMain function at the end is called by the operating system 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 1 页,共 11 页 - - - - - - - - - - allocates space assignment The program design includes: the definition of WinMain function to create a window to create a mes
6、sage loop write window procedure four step window: design a window class (fill in the blank window display status includes cursor display background loading icon loadicon window function lpfnWndProc message response function by its own operating system, but need to write code to call) registered win
7、dow class Registerclass to create a window (createWindow window size coordinate menu handle and update updateWindow ShowWindow) display window of each function type operating system is basically fixed again to set a message loop while (GetMessage (corresponding to the message size and member variabl
8、es) the corresponding application message queue) to achieve continuous operation program (background) TranslateMessage (converted to wchar) The distribution (dispatchmessage to the middle layer of the callback function for operating system) the last message editing window function switch (process to
9、 deal with the mouse button to destroy the window and the end of the news program plus default) prompt: the system is through the window function address (pointer) to invoke the process window function 2, about c+ C+ has more advantages over C, mainly in encapsulation, inheritance and polymorphism S
10、elect new project Win32 console application c+ source file written in structure c+ body can write function of foreign body and the structure can call the member variable c+ function in 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 2 页,共 11 页 - - - - - - - - - - similar but by
11、default to the member variable access is not the same An instance of a class and object instantiated with an object that defines a structure variable is to produce an object Constructor: the important function is to create the object itself, and each object must have a constructor that has the same
12、form as the class name and has no return value, In a statement object will automatically call the default constructor is a constructor with no parameters are only responsible for creating object not initialized if the definition of a parameter or a zeroary constructor, c+ will not create a default c
13、onstructor Destructor: the object is responsible for retrieving its memory space at the end of the objects life. In contrast to the constructor, the arguments and return values are not allowed, and a class can only have one destructor. Overloading of functions: if the constructor overloads, c+ autom
14、atically matches the call to the corresponding function, overloading the condition: the parameter type of the function and the number of arguments This pointer: an implicit pointer to an object corresponding to itself, representing the address of the object (this=&pt). This makes it easy to write th
15、e member variables in the object (using VCs automatic listing of member functions, using this ) 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 3 页,共 11 页 - - - - - - - - - - Base class inheritance and access characteristics of the three kinds of subclasses to inherit father to
16、see the definition of property inheritance characteristics and the parent class member function decision, protected in subclassing but outside (such as fish.breath (main) in the function cannot be called by the fish class but can not be inherited) visit the subclass inheritance, if the parent class
17、with parameters, the subclass inheritance should also add parameters, the constructor call the parent class and subclass, and the destructor calls in reverse order Overlay of functions: a member variable that occurs between the two classes of a parent class and a subclass. The name of the function i
18、s consistent. Scope identifier (:) used to indicate which class of member variables the function belongs to and prevents the coverage of the member functions of the parent class Polymorphism: virtual in the base class member function, sub class inheritance, VC sub class visit, sub class has a member
19、 function with the same name is called sub classes, subclasses did not call the parent class. Another: pure virtual functions appear in base classes, but are implemented by derived classes Reference and pointer: int a=5; int &b=a; a, B, point to the same memory space at the same time, AB is an alias
20、 pointer, and the variable itself occupies memory, which stores the content as the address pointing to the variable For write method of.Cpp file and.H file, create different files 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 4 页,共 11 页 - - - - - - - - - - in the open the proj
21、ect can also be found in the project file new text file (later renamed F2, VC function keys) to add one to write different engineering documents VC program to compile and link mechanism: precompiled , and when the project file is established to find the solution to the project file, header file cont
22、ains repeated problems: #ifdef XX #define XX (preparation) after adding ENDIF, repeat this definition can prevent the error, prevent the VC compilation process mechanism integration: the pre processor to the pre compiled instruction compiler (#) to project source code (.Cpp) separately compiled mach
23、ine instructions contains different object file (debag.Obj file), and finally by the connector to the target file (.Obj) and c+ standard library function standard library (.Lib) to generate a the executable file (.Exe). Tip: compile time to troubleshoot.Cpp source files individually! 3 MFC programmi
24、ng An object oriented library of functions is provided to users in a class manner MFC AppWizard is used to create a single document based on the MFC interface (SDI) applications, the new MFC AppWizard generation program dialog box click OK can see the operation of the program, on the left side of VC
25、 workspace classview tag can be seen in the five class of the automatically generated, only need to turn on the following class you can write code First of all, to understand the internal mechanism of MFC, you 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 5 页,共 11 页 - - - - -
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022 学习 笔记

限制150内