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

📄 0484-0486.html

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




<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:C and C++ Programming</TITLE>

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

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=23 //-->

<!-- PAGES=0455-0486 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0481-0483.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch24/0487-0490.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-484"><P>Page 484</P></A>













<P>New C++ classes (and hence datatypes) can be defined so that they automatically

inherit the properties and algorithms associated with their parent classes. This is done whenever a

new class uses any of the standard C datatypes. The class from which new class definitions are

created is called the base class. For example, a structure that includes integer members will

also inherit all the mathematical functions associated with integers. New classes that are defined

in terms of the base classes are called derived

classes. The Circle class in Listing 23.15 is a

derived class.

</P>









<P>Derived classes can be based upon more than one base class, in which case the derived

class inherits multiple datatypes and their associated functions. This is

called multiple inheritance.

</P>









<P>Because functions can be overloaded, it is possible that an object declared as a member of

a derived class might act differently than an object of the base class type. For example, the

class of positive integers might return an error if the program attempts to assign a negative

number to a class object, although such an assignment would be legal with regard to an object of

the base integer type.

</P>









<P>This ability of different objects within the same class hierarchy to act differently under the

same circumstances is referred to as polymorphism. Polymorphism is the object-oriented concept

that many people have the most difficulty grasping. However, it is also the concept that

provides much of the power and elegance of object-oriented design and code. A programmer

designing an application using predefined graphical user interface (GUI) classes, for instance, is free

to ask various window objects to display themselves appropriately without having to concern

herself with how the window color, location, or other display characteristics are handled in each case.

</P>









<P>Class inheritance and polymorphism are among the most powerful object-oriented features

of C++. Together with the other less dramatic extensions to C, these features have made

possible many of the newest applications and systems capabilities of UNIX today, including GUIs

for user terminals and many of the most advanced Internet and World Wide Web

technologies&#151;some of which will be discussed in the subsequent chapters of

this book.

</P>









<H3><A NAME="ch23_ 28">

GNU C/C++ Compiler Command-Line Switches

</A></H3>









<P>There are many options available for the GNU C/C++ compiler. Many of them match the

C and C++ compilers available on other UNIX systems. Table 23.7 shows the important

switches; look at the man page for gcc or the info file on the CD-ROM for the full list and description.

</P>









<P>Table 23.7. GNU C/C++ compiler switches.

</P>



<HR>

<TABLE WIDTH="360">

<TR><TD>

Switch

</TD><TD>

Description

</TD></TR>



<TR><TD>

-x language

</TD><TD>

Specifies the language (C, C++, and assembler are valid values)

</TD></TR>



<TR><TD>

-c

</TD><TD>

Compiles and assembles only (does not link)

</TD></TR>



<TR><TD>

-S

</TD><TD>

Compiles (does not assemble or link)

</TD></TR>

</TABLE>





<A NAME="PAGENUM-485"><P>Page 485</P></A>



<BR>







<TABLE WIDTH="360">

<TR><TD>

Switch

</TD><TD>

Description

</TD></TR>



<TR><TD>

-E

</TD><TD>

Preprocesses only (does not compile, assemble, or

link)

</TD></TR>



<TR><TD>

-o file

</TD><TD>

Specifies the output filename

(a.out is the default)

</TD></TR>



<TR><TD>

-l library

</TD><TD>

Specifies the libraries to use

</TD></TR>



<TR><TD>

-I directory

</TD><TD>

Searches the specified directory for include files

</TD></TR>



<TR><TD>

-w

</TD><TD>

Inhibits warning messages

</TD></TR>



<TR><TD>

-pedantic

</TD><TD>

Strict ANSI compliance required

</TD></TR>



<TR><TD>

-Wall

</TD><TD>

Prints additional warning messages

</TD></TR>



<TR><TD>

-g

</TD><TD>

Produces debugging information (for use with

gdb)

</TD></TR>



<TR><TD>

-p

</TD><TD>

Produces information required by proff

</TD></TR>



<TR><TD>

-pg

</TD><TD>

Produces information for use by groff

</TD></TR>



<TR><TD>

-O

</TD><TD>

Optimizes

</TD></TR>

</TABLE>









<H3><A NAME="ch23_ 29">

Additional Resources

</A></H3>









<P>If you are interested in learning more about C and C++, you should look into the

following books:

</P>









<UL>

<LI>          Teach Yourself C in 21

Days, by Peter Aitken and Bradley Jones

<LI>          C How to

Program and C++ How to Program, by H.M. Deitel and P.J. Deitel

<LI>          The C Programming

Language, by Brian Kernighan and Dennis Ritchie

<LI>          The Annotated C++ Reference

Manual, by Margaret Ellis and Bjarne Stroustrup

<LI>          Programming in ANSI

C, by Stephen G. Kochan

</UL>









<H3><A NAME="ch23_ 30">

Summary

</A></H3>









<P>UNIX was built upon the C language. C is a platform-independent, compiled, procedural

language based on functions and the ability to derive new, programmer-defined data structures.

</P>









<P>C++ extends the capabilities of C by providing the necessary features for object-oriented

design and code. C++ compilers correctly compile ANSI C code. C++ also provides some

features, such as the ability to associate functions with data structures, which don't require the

use of full class-based, object-oriented techniques. For these reasons, the C++ language allows

existing UNIX programs to migrate toward the adoption of object orientation over time.

</P>





<A NAME="PAGENUM-486"><P>Page 486</P></A>













<P><CENTER>

<a href="0481-0483.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch24/0487-0490.html">Next</A>

</CENTER></P>









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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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