⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 494-497.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Programming in C&#43;&#43;</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=27//-->

<!--PAGES=494-497//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="491-494.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="497-499.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H3><A NAME="Heading11"></A><FONT COLOR="#000077">Summary of gdb C&#43;&#43; Specific Commands</FONT></H3>

<P>In addition to the <TT>gdb</TT> commands that have been added to support some of the new language features contained in C&#43;&#43;, there are also some new <TT>set</TT> and <TT>show</TT> options. These options are listed in Table 27.3.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 27.3.</B> <TT>gdb</TT>&#146;s C&#43;&#43; set and show options.

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="40%" ALIGN="LEFT">Command

<TH WIDTH="60%" ALIGN="LEFT">Description

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD VALIGN="TOP"><TT>set print demangle</TT>

<TD>Prints C&#43;&#43; names in their source form rather than in the encoded or mangled form that is passed to the assembler.

<TR>

<TD><TT>show print demangle</TT>

<TD>Shows whether <TT>print demangle</TT> is on or off.

<TR>

<TD VALIGN="TOP"><TT>set demangle-style</TT>

<TD>Sets the style of demangled output. The options are <TT>auto</TT>, <TT>gnu</TT>, <TT>lucid</TT>, and <TT>arm</TT>.

<TR>

<TD><TT>show demangle-style</TT>

<TD>Shows which demangle style is being used.

<TR>

<TD VALIGN="TOP"><TT>set print object</TT>

<TD>When displaying a pointer to an object, identifies the actual type of the object.

<TR>

<TD><TT>show print object</TT>

<TD>Shows whether <TT>print object</TT> is turned on or off.

<TR>

<TD><TT>set print vtbl</TT>

<TD>Prints C&#43;&#43; virtual function tables.

<TR>

<TD><TT>show print vtbl</TT>

<TD>Shows whether <TT>print vtbl</TT> is turned on or off.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<H3><A NAME="Heading12"></A><FONT COLOR="#000077">GNU C&#43;&#43; Class Libraries</FONT></H3>

<P>GNU C&#43;&#43; comes packaged with an extensive class library. A class library is a reusable set of classes that can be used to perform a specified set of functions. Some typical examples of class libraries are class libraries that handle database access, class libraries that handle graphical user interface programming, and class libraries that implement data structures.

</P>

<P>Other examples of graphical user interface class libraries are the Microsoft Foundation Classes and Borland&#146;s Object Windows Library, both of which are class libraries used for developing Windows applications.</P>

<P>This section introduces several of the features that are offered by the GNU C&#43;&#43; class library.</P>

<H4 ALIGN="LEFT"><A NAME="Heading13"></A><FONT COLOR="#000077">Streams</FONT></H4>

<P>The GNU iostream library, called <TT>libio</TT>, implements GNU C&#43;&#43;&#146;s standard input and output facilities. This library is similar to the I/O libraries that are supplied by other C&#43;&#43; compilers. The main parts of the iostream library are the input, output, and error streams. These correspond to the standard input, output, and error streams that are found in C and are called <TT>cin</TT>, <TT>cout</TT>, and <TT>cerr</TT>, respectively. The streams can be written to and read from using the <TT>&lt;&lt;</TT> operator for output and the <TT>&gt;&gt;</TT> operator for input.</P>

<P>The following program uses the iostream library to perform its input and output:</P>

<!-- CODE SNIP //-->

<PRE>

#include &lt;iostream.h&gt;

int maim ()

&#123;

        char name[10];

        cout &lt;&lt; &#147;Please enter your name.\n&#148;;

        cin &gt;&gt; name;

        cout &lt;&lt; &#147;Hello &#147; &lt;&lt; name &lt;&lt; &#147; how is it going?\n&#148;;

&#125;

</PRE>

<!-- END CODE SNIP //-->

<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077">Strings</FONT></H4>

<P>The GNU string class extends GNU C&#43;&#43;&#146;s string manipulation capabilities. The string class essentially replaces the character array definitions that existed in C and all the string functions that go along with the character arrays.

</P>

<P>The string class adds UNIX shell type string operators to the C&#43;&#43; language, as well as a large number of additional operators. Table 27.4 lists many of the operators that are available with the string class.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 27.4.</B> String class operators.

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="40%" ALIGN="LEFT">Operator

<TH WIDTH="60%" ALIGN="LEFT">Meaning

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD><TT>str1 == str2</TT>

<TD>Returns <TT>TRUE</TT> if <TT>str1</TT> is equal to <TT>str2</TT>

<TR>

<TD><TT>str1 != str2</TT>

<TD>Returns <TT>TRUE</TT> if <TT>str1</TT> is not equal to <TT>str2</TT>

<TR>

<TD><TT>str1 &lt; str2</TT>

<TD>Returns <TT>TRUE</TT> if <TT>str1</TT> is less than <TT>str2</TT>

<TR>

<TD><TT>str1 &lt;= str2</TT>

<TD>Returns <TT>TRUE</TT> if <TT>str1</TT> is less than or equal to <TT>str2</TT>

<TR>

<TD><TT>str1 &gt; str2</TT>

<TD>Returns <TT>TRUE</TT> if <TT>str1</TT> is greater than <TT>str2</TT>

<TR>

<TD><TT>str1 &gt;= str2</TT>

<TD>Returns <TT>TRUE</TT> if <TT>str1</TT> is greater than or equal to <TT>str2</TT>

<TR>

<TD VALIGN="TOP"><TT>compare(str1,str2)</TT>

<TD>Compares <TT>str1</TT> to <TT>str2</TT> without considering the case of the characters

<TR>

<TD VALIGN="TOP"><TT>str3 = str1 &#43; str2</TT>

<TD>Stores the result of <TT>str1</TT> concatenated with <TT>str2</TT> into <TT>str3</TT>

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P>A number of other operators are available in the string class for performing different types of string comparisons, concatenations, and substring extraction and manipulation.

</P>

<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077">Random Numbers</FONT></H4>

<P>Classes are provided in the GCC C&#43;&#43; class library that allow you to generate several different kinds of random numbers. The classes used to generate these numbers are the Random class and the RNG class.

</P>

<H4 ALIGN="LEFT"><A NAME="Heading16"></A><FONT COLOR="#000077">Data Collection</FONT></H4>

<P>The class library provides two different classes that perform data collection and analysis functions. The two classes are <TT>SampleStatistic</TT> and <TT>SampleHistogram</TT>. The <TT>SampleStatistic</TT> class provides a way of collecting samples and also provides numerous statistical functions that can perform calculations on the collected data. Some of the calculations that can be performed are mean, variance, standard deviation, minimum, and maximum.</P>

<P>The <TT>SampleHistogram</TT> class is derived from the <TT>SampleStatistic</TT> class and supports the collection and display of samples in bucketed intervals.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="491-494.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="497-499.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -