📄 apb.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"> <META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1"> <TITLE>Teach Yourself Visual C++® 5 in 24 Hours -- Appendix B -- Quiz Answers</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"BORDER="0"><BR><FONT COLOR="#000077">Teach Yourself Visual C++® 5 in 24 Hours</FONT></H1><CENTER><P><A HREF="../apa/apa.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../index.htm"><IMGSRC="../button/contents.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Contents"BORDER="0"></A> <HR></CENTER><H1 ALIGN="CENTER"><FONT COLOR="#000077">- Appendix B -<BR>Quiz Answers</FONT></H1><P>This appendix lists the answers to the quiz questions in the Workshop sectionsat the end of each hour.<H2><FONT COLOR="#000077"><B>Hour 1 Quiz</B></FONT></H2><DL> <DD>1. A library is a collection of reusable source code or compiled code that can be used in a program. The MFC class library and the standard C++ library are examples of commonly used libraries.<BR> <BR> 2. A project is built by using one of these steps:</DL><OL> <UL> <LI>Pressing F7 on the keyboard<BR> <BR> <LI>Clicking the Build button on the toolbar<BR> <BR> <LI>Selecting Build | Build from the main menu<BR> <BR> </UL></OL><DL> <DD>3. A wizard is a tool similar to a dialog box that guides you through a series of steps.<BR> <BR> 4. AppWizard, ClassWizard, and ControlWizard<BR> <BR> 5. Press the F1 function key.<BR> <BR> 6. ClassView, FileView, ResourceView, and InfoView<BR> <BR> 7. <TT>OnDraw</TT><BR> <BR> 8. The F7 function key<BR> <BR> 9. Ctrl+Z <P>10. Undo reverses an action; Redo reverses an Undo.</DL><H2><FONT COLOR="#000077"><B>Hour 2 Quiz</B></FONT></H2><DL> <DD>1. The <TT>cout</TT> <TT>iostream</TT> object is used to display output to a console-mode window. The <TT>cin</TT> <TT>iostream</TT> object is used to collect input from the keyboard.<BR> <BR> 2. When including project-specific files that are located in the project directory, use quotes around the header filename, as in the following:</DL><BLOCKQUOTE> <PRE><FONT COLOR="#0066FF"><TT>#include "myfile.h"</TT></FONT></PRE></BLOCKQUOTE><PRE><FONT COLOR="#0066FF"><TT></TT></FONT></PRE><DL> <DD>When including library files that are located in a standard location, use angle brackets around the filename, like this:</DL><BLOCKQUOTE> <PRE><FONT COLOR="#0066FF"><TT>#include <myfile.h></TT></FONT></PRE></BLOCKQUOTE><PRE><FONT COLOR="#0066FF"><TT></TT></FONT></PRE><DL> <DD>3. Character values are stored in variables that have the <TT>char</TT> type. <P>4. A C++ namespace provides a container for a set of names. This prevents identical names in two parts of your application from conflicting with each other.<BR> <BR> 5. To declare multiple variables on one line, separate the variable names with a comma, like this:</DL><BLOCKQUOTE> <PRE><FONT COLOR="#0066FF"><TT>int nFoo, nBar, nBaz;</TT></FONT></PRE></BLOCKQUOTE><PRE><FONT COLOR="#0066FF"><TT></TT></FONT></PRE><DL> <DD>6. Type-safety refers to the capability of a C++ compiler to enforce rules that ensure that variables and functions are used as they are intended. This helps the compiler detect a large number of common errors.<BR> <BR> 7. The floating-point variable types are <TT>float</TT>, <TT>double</TT>, and <TT>long double</TT>.<BR> <BR> 8. The C++ assignment operator is the equals sign, <TT>=</TT>, as in <TT>nFoo = 5;</TT>.<BR> <BR> 9. Integer values are normally stored in variables that have the <TT>int</TT> type. To save space, smaller values may be stored in the <TT>char</TT> and <TT>short int</TT> types. <P>10. If you know that a value will not be negative, you can double the maximum value stored in the variable by declaring it as <TT>unsigned</TT>.</DL><H2><FONT COLOR="#000077"><B>Hour 3 Quiz</B></FONT></H2><DL> <DD>1. Dialog boxes, menus, toolbars, and controls are all examples of windows.<BR> <BR> 2. A function is a group of computer instructions that are grouped together to perform a well-defined task.<BR> <BR> 3. The function's name, return value, parameter list, and function body.<BR> <BR> 4. Classes are exactly like structures, except that members of a class cannot be accessed from outside the class by default.<BR> <BR> 5. The constructor<BR> <BR> 6. The destructor<BR> <BR> 7. The non-client area contains the borders, menu, and caption area; the client area is the area that is left over.<BR> <BR> 8. 42<BR> <BR> 9. The <TT>*</TT> symbol is used for multiplication.<BR> <BR> 10. The <TT>/</TT> symbol is used for division.</DL><H2><FONT COLOR="#000077"><B>Hour 4 Quiz</B></FONT></H2><DL> <DD>1. A modal dialog box prevents the user from interacting with the program until the dialog box is dismissed. A modeless dialog box does not prevent the user from interacting with the program.<BR> <BR> 2. <TT>WM_INITDIALOG</TT><BR> <BR> 3. <TT>.h</TT><BR> <BR> 4. <TT>.cpp</TT><BR> <BR> 5. The warning icon, <TT>MB_ICONEXCLAMATION</TT><BR> <BR> 6. The stop sign icon, <TT>MB_ICONSTOP</TT><BR> <BR> 7. <TT>CDialog</TT><BR> <BR> 8. <TT>DoModal</TT><BR> <BR> 9. <TT>IDYES</TT> <P>10. <TT>IDNO</TT></DL><H2><FONT COLOR="#000077"><B>Hour 5 Quiz</B></FONT></H2><DL> <DD>1. A Cancel button is used to close the dialog box and discard any changes that have been made. A Close button is used to close the dialog box and keep any changes that have been made.<BR> <BR> 2. An OK button is used to close the dialog box and keep any changes that have been made. An Apply button keeps changes that have been made but does not close the dialog box; this button is often used when the Apply button is used to update the application that displays the dialog box.<BR> <BR> 3. <TT>CButton</TT><BR> <BR> 4. Check boxes, radio buttons, pushbuttons, group boxes, and owner-drawn buttons.<BR> <BR> 5. Clear the Tab Stop property for the control.<BR> <BR> 6. <TT>Enable</TT><BR> <BR> 7. <TT>ShowWindow</TT><BR> <BR> 8. The <TT>default</TT> label is selected when no <TT>case</TT> labels match the <TT>switch</TT> expression.<BR> <BR> 9. The <TT>=</TT> operator is used for assignment. The <TT>==</TT> operator is used to test for equality.<BR> <BR> 10. <TT>SetWindowText</TT></DL><H2><FONT COLOR="#000077"><B>Hour 6 Quiz</B></FONT></H2><DL> <DD>1. <TT>CEdit</TT><BR> <BR> 2. An MLE is a multiline edit control and accepts multiple lines of text as input. An SLE is a single-line edit control and accepts single lines of text as input.<BR> <BR> 3. A DDV routine is used to validate data input stored in a control. A DDX routine is used to transfer data to or from a control.<BR> <BR> 4. <TT>UpdateData</TT><BR> <BR> 5. <TT>GetWindowText</TT><BR> <BR> 6. <TT>SetWindowText</TT><BR> <BR> 7. Password<BR> <BR> 8. Ctrl+V<BR> <BR> 9. Ctrl+C<BR> <BR> 10. Ctrl+X</DL><H2><FONT COLOR="#000077"><B>Hour 7 Quiz</B></FONT></H2><DL> <DD>1. <TT>CListBox</TT><BR> <BR> 2. <TT>LBN_DBLCLCK</TT><BR> <BR> 3. <TT>AddString</TT> and <TT>InsertString</TT><BR> <BR> 4. <TT>GetCount</TT><BR> <BR> 5. <TT>GetCurSel</TT><BR> <BR> 6. Single-selection, multiple-selection, and extended-selection<BR> <BR> 7. <TT>for</TT>, <TT>while</TT>, and <TT>do-while</TT><BR> <BR> 8. <TT>CComboBox</TT><BR> <BR> 9. <TT>InsertString</TT><BR> <BR> 10. Simple, drop-down, and drop list</DL><H2><FONT COLOR="#000077"><B>Hour 8 Quiz</B></FONT></H2><DL> <DD>1. The default window procedure is a special function supplied by Windows that handles messages that aren't handled by the application.<BR> <BR> 2. Messages are physical chunks of data and are easily prioritized. They are not processor or language dependent.<BR> <BR> 3. When the mouse cursor passes over a window, the window receives the <TT>WM_MOUSEMOVE</TT> and <TT>WM_NCMOUSEMOVE</TT> messages.<BR> <BR> 4. A message map is used to associate a message with a function used to process that message.<BR> <BR> 5. <TT>CObject</TT> is the base class for most MFC classes.<BR> <BR> 6. The <TT>Dump</TT> function is used to display debug information about the current state of an object.<BR> <BR> 7. The <TT>ASSERT</TT> macro is used to test an expression that is not needed when the program is compiled for release mode. The <TT>VERIFY</TT> macro is used to test an expression that is used when the program is compiled for release mode. When compiled for release mode, the <TT>ASSERT</TT> macro and the expression contained inside it will be removed; the <TT>VERIFY</TT> macro is also removed, but its contained expression is compiled.<BR> <BR> 8. <TT>WM_LBUTTONDOWN</TT><BR> <BR> 9. The message map entries reserved for use by ClassWizard begin with <TT>//{{AFX_MSG_MAP</TT> and end with <TT>//}}AFX_MSG_MAP</TT>.</DL><H2><FONT COLOR="#000077"><B>Hour 9 Quiz</B></FONT></H2><DL> <DD>1. The <TT>sizeof</TT> operator returns the number of bytes required to hold an object.<BR> <BR> 2. A pointer that points to one variable can be changed to point to another variable; references must be bound to a single variable for their lifetime. A reference to a class uses <TT>.</TT> to access a member, a pointer to a class uses the <TT>-></TT> operator.<BR> <BR> 3. Passing a point to an object rather than the object itself is almost always more efficient. Passing a pointer parameter is a 32-bit variable; passing an object such as a class instance requires that a copy be made of the instance--and not only must the copy be made, it must be destroyed after the copy is no longer needed.<BR> <BR> 4. The <TT>new</TT> keyword is used to dynamically allocate memory.<BR> <BR> 5. The <TT>delete</TT> keyword is used to release memory allocated with <TT>new</TT>.<BR> <BR> 6. Classes derived from <TT>CView</TT> are responsible for the user interface.<BR> <BR> 7. The four classes are</DL><OL> <UL> <LI>Document classes derived from <TT>CDocument</TT><BR> <BR> <LI>View classes derived from <TT>CView</TT><BR> <BR> <LI>Frame classes derived from <TT>CFrameWnd</TT><BR> <BR> <LI>Application classes derived from <TT>CWinApp</TT><BR> <BR> </UL></OL><DL> <DD>8. The document class is responsible for an application's data.<BR> <BR> 9. The <TT>GetDocument</TT> function returns a pointer to the document associated with a view.<BR> <BR> 10. A document class uses <TT>UpdateAllViews</TT> to notify views associated with the document that their user interfaces might need to be updated.</DL><H2><FONT COLOR="#000077"><B>Hour 10 Quiz</B></FONT></H2><DL> <DD>1. The <TT>CMenu</TT> class<BR> <BR> 2. The <TT>WM_CONTEXTMENU</TT> message<BR> <BR> 3. An ellipsis (...) after the menu item<BR> <BR> 4. A letter that is used to represent the menu item, such as x in Exit<BR> <BR> 5. A keyboard shortcut to a message-handling function</DL><H2><FONT COLOR="#000077"><B>Hour 11 Quiz</B></FONT></H2><DL> <DD>1. An information context cannot be used for output.<BR> <BR> 2. <TT>SelectStockObject</TT><BR> <BR> 3. Approximately 1440<BR> <BR> 4. A pen<BR> <BR> 5. A brush<BR> <BR> 6. Use the <TT>GetTextMetrics</TT> function.<BR> <BR> 7. <TT>RGB</TT> is used to create a <TT>COLORREF</TT> value.<BR> <BR> 8. <TT>CDC</TT><BR> <BR> 9. If <TT>SelectObject</TT> returns <TT>NULL</TT>, the call failed. <P>10. <TT>MM_TEXT</TT></DL><H2><FONT COLOR="#000077"><B>Hour 12 Quiz</B></FONT></H2><DL> <DD>1. Width, color, and style<BR> <BR> 2. Cosmetic and geometric<BR> <BR> 3. <TT>CPen</TT><BR> <BR> 4. <TT>BLACK_PEN</TT>, <TT>WHITE_PEN</TT>, and <TT>NULL_PEN</TT><BR> <BR> 5. <TT>PS_SOLID</TT>, <TT>PS_DASH</TT>, <TT>PS_DOT</TT>, <TT>PS_DASHDOT</TT>, <TT>PS_DASHDOTDOT</TT>, <TT>PS_NULL</TT>, <TT>PS_INSIDEFRAME</TT>, and <TT>PS_ALTERNATE</TT><BR> <BR> 6. <TT>PS_SOLID</TT>, <TT>PS_DASH</TT>, <TT>PS_DOT</TT>, <TT>PS_DASHDOT</TT>, <TT>PS_DASHDOTDOT</TT>, <TT>PS_NULL</TT>, and <TT>PS_INSIDEFRAME</TT><BR> <BR> 7. Solid, hatch, pattern, and stock<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -