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

📄 ch01.html

📁 《Big C++ 》Third Edition电子书和代码全集-Part1
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html>
<head>
<title>Introduction</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<h2>Chapter 1: Introduction</h2>
<p align="center"><img src="images/ccc_4.png"></p>
<h2>Chapter Goals</h2>
<ul>
  <li><font size="+1">To understand the activity of programming</font></li>
  <li><font size="+1">To learn about the architecture of computers</font></li>
  <li><font size="+1">To learn about machine languages and higher-level programming 
    languages</font></li>
  <li><font size="+1">To become familiar with your compiler</font></li>
  <li><font size="+1">To compile and run your first C++ program</font></li>
  <li><font size="+1">To recognize syntax and logic errors</font></li>
</ul>
<h2>What is a Computer?</h2>
<ul>
  <li><font size="+1">Computers can handle <i>repetitive</i> chores without becoming 
    bored or exhausted.</font></li>
  <li><font size="+1">A computer is <i>programmable</i> to handle different tasks: 
    </font> 
    <ul>
      <li><font size="+1">Balancing checkbooks</font></li>
      <li><font size="+1">Processing words</font></li>
      <li><font size="+1">Playing Games</font></li>
    </ul>
  </li>
  <li><font size="+1">Computer actions are composed of <i>huge numbers</i> of 
    extremely <i>primitive</i> operations</font></li>
  <li><font size="+1">The computer gives the <i>illusion</i> of smooth interaction 
    because it executes these operations a <i>great speed</i>.</font></li>
  <li><font size="+1">Computers are <i>flexible</i>: they can handle a wide range 
    of tasks.</font></li>
</ul>
<h2>What is Programming?</h2>
<ul>
  <li><font size="+1">A <i>program</i> tells the computer the sequence of steps 
    needed to fulfill a task.</font></li>
  <li><font size="+1">A <i>programmer</i> designs and implements these programs.</font></li>
  <li><font size="+1">Most computer <i>users</i> are <b><u>not</u></b> computer 
    programmers.</font></li>
  <li><font size="+1">Programming is an <i>essential</i> <i>skill</i> for a computer 
    scientist.</font></li>
  <li><font size="+1">Programming is <u><b>not</b></u> the only skill required 
    to be a successful computer scientist.</font></li>
  <li><font size="+1">Early programming experiences are mundane and will not rival 
    sophisticated software that you are familiar with.</font></li>
  <li><font size="+1">Once certain skills are developed, even simple programs 
    can be thrilling.</font></li>
</ul>
<h2>The Anatomy of a Computer (CPU, Memory, and bus)</h2>
<ul>
  <li><font size="+1">CPU (Central Processing Unit): </font>
    <ul>
      <li><font size="+1">Plastic, metal and mostly silicon.</font></li>
      <li><font size="+1">Composed of several million transistors.</font></li>
      <li><font size="+1">Enormously complicated wiring.</font></li>
      <li><font size="+1">Performs program control, arithmetic, and data movement.</font></li>
      <li><font size="+1">Locates and executes program instructions.</font></li>
    </ul>
  </li>
  <li><font size="+1">Memory: </font>
    <ul>
      <li><font size="+1">RAM (Random Access Memory): read-write memory.</font></li>
      <li><font size="+1">ROM (Read Only Memory): contains certain programs that 
        must always be present.</font></li>
      <li><font size="+1">Secondary storage (e.g. a hard drive) provides <i>persistent</i> 
        storage.</font></li>
    </ul>
  <LI><font size="+1">The <i>bus</i> is a set of electrical lines that connect 
    the CPU, RAM, and other devices.</font></li>
</ul>
<h2>The Anatomy of a Computer (Motherboard, Peripherals, and Networks)</h2>
<ul>
  <li><font size="+1">The <i>motherboard</i> holds the CPU, memory, and bus, as 
    well as card slots which connect peripherals to the computer.</font></li>
  <li><font size="+1"><i>Peripherals</i> allow the user and computer to interact: 
    </font> 
    <ul>
      <li><font size="+1">Printer</font></li>
      <li><font size="+1">Mouse</font></li>
      <li><font size="+1">Keyboard</font></li>
      <li><font size="+1">Modem</font></li>
    </ul>
  </li>
  <li><font size="+1">Some computers are connected to one another through <i>networks</i>.</font></li>
</ul>
<h2>The Anatomy of a Computer (Schematic)</h2>
<p><img src="images/schematic.png"> </p>
<h2>Translating Human-Readable Programs to Machine Code (Machine Instructions)</h2>
<ul>
  <li><font size="+1">Machine instructions: </font>
    <ul>
      <li><font size="+1">Extremely primitive:</font></li>
      <li><font size="+1">Encoded as numbers:<br>
        <pre>161 40000 45 100 127 11280</pre></font></li>
      <li><font size="+1">Tedious and error prone to look up numeric codes and 
        enter them manually.</font></li>
      <li><font size="+1">Each processor has its own set of machine instructions.</font></li>
    </ul>
  </li>
</ul>
<h2>Translating Human-Readable Programs to Machine Code (Assembler)</h2>
<ul>
  <li><font size="+1">Assembler</font> 
    <ul>
      <li><font size="+1">Assigns short names to commands: </font> 
        <pre><font size="+1">mov 40000, %eax
sub 100, %eax
jg 11280</font></pre>
      </li>
      <li><font size="+1">Makes reading easier for humans.</font></li>
      <li><font size="+1">Translated into machine instructions by another program.</font></li>
      <li><font size="+1">Still processor dependent</font></li>
    </ul>
  </li>
</ul>
<h2>Translating Human-Readable Programs to Machine Code (Higher-level Languages)</h2>
<ul>
  <li><font size="+1">Higher-level languages: </font>
    <ul>
      <li><font size="+1">Independent of the underlying hardware. </font></li>
      <li><font size="+1">Easiest for humans to read and write.<br>
        </font>
        <pre><font size="+1">if (int_rate > 100) message_box("Interest rate error");</font></pre>
      </li>
      <li><font size="+1">Translated by <i>compilers</i> into machine instructions.</font> 
      </li>
    </ul>
  </li>
</ul>
<h2>Programming Languages</h2>
<ul>
  <li><font size="+1">Compilers follow strict conventions regarding programming 
    language use.</font></li>
  <li><font size="+1">Strict rules prevent more disastrous errors that could arise 
    should the compiler &quot;guess.&quot;</font></li>
  <li><font size="+1">There are many (hundreds of) programming languages. </font></li>
  <li><font size="+1">Differences in programming languages are sometimes slight, 
    but at other times substantial.</font> 
    <ul>
      <li><font size="+1">C++:<br>
        <pre>if (int_rate > 100) message_box("Interest rate error");</pre></font></li>
      <li><font size="+1">Pascal:<br>
        <pre>if int_rate > 100 then message_box('Interest rate error');</pre></font> </li>
    </ul>
  </li>
</ul>
<h2>Programming Language Design and Evolution (Specific and General Purpose Languages)</h2>
<ul>
  <li><font size="+1">Many programming languages are created with a specific purpose.</font> 
    <ul>
      <li><font size="+1">database processing.</font></li>
      <li><font size="+1">&quot;artificial intelligence.&quot;</font></li>
      <li><font size="+1">multimedia processing.</font></li>
    </ul>
  </li>
  <li><font size="+1">Special-purpose languages are not used much beyond their 
    area of specialization.</font></li>
  <li><font size="+1">General purpose languages can be used for any task.</font> 
    <ul>
      <li><font size="+1">Pascal: designed as a teaching language (purposefully 
        kept simple).</font></li>
      <li><font size="+1">C: developed to be translated efficiently into fast 
        machine code, with a minimum of housekeeping.</font></li>
      <li><font size="+1">C++: adds &quot;object oriented programming&quot; aspects 
        to C.</font></li>
    </ul>
  </li>
</ul>
<h2>Programming Language Design and Evolution (Incremental Growth)</h2>
<ul>
  <li><font size="+1">C and C++ are languages that grew in increments; as the 
    users of the language perceived shortcomings, they added features:</font> 
    <ul>
      <li><font size="+1">1972 - original design of C. Many compilers add different 
        features, sprouting dialects of C.</font></li>
      <li><font size="+1">1985 - Bjarne Stroustrup of AT&amp;T adds object oriented 
        features to C, creating C++. </font></li>
      <li><font size="+1">1989 - ANSI standard of C developed to resolve differences 
        among the several version of C.</font></li>
      <li><font size="+1">1998 - Standards developed for most recent version of 
        C++.</font></li>
    </ul>
  </li>
  <li><font size="+1">Grown languages tend to be messy; different features are 
    added by people with different tastes.</font></li>
  <li><font size="+1">Grown languages are modified in a hurry to solve a specific 
    need, without considering the consequences.</font></li>
  <li><font size="+1">Grown languages accumulate a patchwork of features that 
    do not necessarily interact well together.</font></li>
  <li><font size="+1">Grown languages have an edge in the marketplace (C++ allows 
    programmers to use new features without throwing away old C code).</font></li>
</ul>
<h2>Programming Language Design and Evolution (Planned Languages)</h2>
<ul>
  <li><font size="+1">Planned languages (such as Pascal and Ada) are carefully 
    designed to anticipate the needs of future users.</font></li>
  <li><font size="+1">More thought goes into planned languages.</font></li>
  <li><font size="+1">Features of planned languages tend to be more related to 

⌨️ 快捷键说明

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