📄 page_860.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_860</title> <link rel="stylesheet" href="reset.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <table summary="top nav" border="0" width="100%"> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_859.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_860</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_861.html">next page ></a></td> </tr> <tr> <td align="left" colspan="3" style="background: #ffffff; padding: 20px;"> <table border="0" width="100%" cellpadding="0"><tr><td align="center"> <table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td align="left"></td> <td align="right"></td> </tr></table></td></tr><tr><td align="left"><p></p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="right"><font face="Times New Roman, Times, Serif" size="2" color="#FF0000">Page 860</font></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">Returning to our </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">TimeType</font><font face="Times New Roman, Times, Serif" size="3"> class, let's assume we have used the system's editor to create the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">timetype.h</font><font face="Times New Roman, Times, Serif" size="3"> and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">timetype.cpp</font><font face="Times New Roman, Times, Serif" size="3"> files. Now we can compile </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">timetype.cpp</font><font face="Times New Roman, Times, Serif" size="3"> into object code. If we are working at the operating system's command line, we use a command similar to the following:</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">cc聽-c聽timetype.cpp</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">In this example, we assume that </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">cc</font><font face="Times New Roman, Times, Serif" size="3"> is the name of a command that invokes either the C++ compiler or the linker or both, depending on various options given on the command line. The command-line option </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">-c</font><font face="Times New Roman, Times, Serif" size="3"> means, on many systems, compile but do not link. In other words, this command produces an object code file, say, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">timetype.obj</font><font face="Times New Roman, Times, Serif" size="3">, but does not attempt to link this file with any other file.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">A programmer wishing to use the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">TimeType</font><font face="Times New Roman, Times, Serif" size="3"> class will write code that </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">#includes</font><font face="Times New Roman, Times, Serif" size="3"> the file </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">timetype.h</font><font face="Times New Roman, Times, Serif" size="3">, then declares and uses </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">TimeType</font><font face="Times New Roman, Times, Serif" size="3"> objects:</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">#include聽timetype.h<br />聽.<br />聽.<br />聽.<br />TimeType聽appointment;<br /><br />appointment.Set(15,聽30,聽0);<br />appointment.Write();<br />聽.<br />聽.<br />聽.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">If this client code is in a file named </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">diary.cpp</font><font face="Times New Roman, Times, Serif" size="3">, an operating system command like</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">cc聽diary.cpp聽timetype.obj</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">compiles the client program into object code, links this object code with </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">timetype.obj</font><font face="Times New Roman, Times, Serif" size="3">, and produces an executable program (see Figure 15-7).</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">The mechanics of compiling, linking, and executing vary from one computer system to another. The examples we gave using the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">cc</font><font face="Times New Roman, Times, Serif" size="3"> command assume you are working at the operating system's command line. Some C++ systems provide an <i>integrated environment</i>a program that bundles the editor, the compiler, and the linker into one package. Integrated environments put you back into the editor when a compile-time or link-time error occurs, pinpointing the location of the error. Some integrated environments also manage <i>project files.</i> Project files contain information about all the con-</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><p><font size="0"></font></p>聽 </td> </tr> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_859.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_860</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_861.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -