Object-Oriented Programming using C++

Introduction

Anne DeFrance

CS 210

Class information on the web

      Syllabus includes:

   Text

   Grading criteria

   Final time

   Office hours

      Lecture schedule includes

   Reading assignments

   Schedule of lecture topics and exams

   Most of the lectures will be posted after class

   Link to assignments

 

 

What is expected in this course

  You come to class

   there will be quizzes which will be 15% of your grade.

  You read the material before you come to class

   There is required reading and reference reading.

  You ask questions in class if you need clarification

  You do your own programming.

  You keep your web page current.

 

The evolution of computers

      The first US computers were developed during WWII to plot artillery trajectories.

    In England, the first computer helped win the war by cracking the German code

      In the 50s and 60s, companies used mainframe computers costing millions of dollars, and big as a room

    Input was with punched cards, and only one job could run at a time

      By the 70s, minicomputers had been developed

    The PDP-11 Weiss talks about was a minicomputer

    128 K of RAM

    The C compiler took 30 seconds to compile a 100 line program

    The C language was developed to run on this machine

 

The evolution of computer languages

      The first computers used machine language (zeros and ones)

    This was implemented by plugging and unplugging wires

      Assembly language was developed to avoid the zeros and ones

    There is a one-to-one correspondence between a machine instruction and an assembly language instruction

      High level languages: one instruction may contain several assembly language instructions

    FORTRAN and COBOL were early high level languages

    The C language was developed to write an operating system for a minicomputer (UNIX)

    Java and C++ are higher level languages than C

 

Evolution of C

      Unix proved to be a very popular operating system for several reasons

    It was portable between different platforms

    The source code was given to universities, and they modified (improved) the OS

      This led to a host of venders producing C compilers, adding their own features.

    In 1989 C was  finally standardized (ANSI C)

      About this time Bjarne Stroustrup created C++ based on C, but object oriented

      C++ should be view as a completely new language, based largely on C.

 

From C to C++

      C++ was designed to be upward compatible with C

   A C program should compile on a C++ compiler

   If the C program uses any of the C++ new reserved words, it will not compile

   So, not too many reserved words were added to C++

      C++ has evolved.  A new standard was established in 1999.

   At first, compilers had trouble implementing all the features of the new standard.

 

Philosophical differences between Java and C++

      C++’s main priority is getting correct programs to run as fast as possible

   Incorrect programs get no help from the compiler

   This means fewer compiler errors and more runtime errors

      Java’s main priority is not allowing incorrect programs to run.

   This means more compiler errors and fewer runtime errors.

 

Translating differences between Java and C++

      Java is compiled into bytecode, then interpreted into executable code.

   You do not get a file with the executable code.

   The .class file is the file containing the bytecode

   This makes the Java code portable.

      The C++ compiler generates executable code.

   This means that what you compile on one machine will not (usually) run on another machine.

 

Some reasons to use C++

            C++ is widely used in industry

           Generic code is fast and relatively easy

           C++ allows operator overloading

           The Standard Template Library is very powerful