CSCI 62 Data Structures Dr Joshua Stough November

CSCI 62 Data Structures Dr. Joshua Stough November 25, 2008

Today • Intro C++ – History – High level differences with Java – Basics – Functions, arrays, strings, parameter passing.

History • C and C++ – C motivated by complexity of assembly code. • Has constructs for pointers, direct memory access, bit operations, other assembly-like functions more efficient compiler output • No initialization check, array boundary check – C++ is object-oriented approach to C • But compatible with C.

High level differences • Java is C++ -lite – Where C++ has many idioms, Java has one. – Java compiler makes it harder to run incorrect code. • Much slower. Used to be 50 x, now less. • C++ - many standards/depends on particular compilers. – No garbage collection – No check for initialization – More wild west.

Advantages of C++ over Java • • Less control on names of files. Class = class. Package = namespace. Generics = templates (Java 1. 5 is after Weiss). – Standard template library – all the data structures and algorithms you’ll likely need. • Simpler to enforce immutability. • Efficiency of space.

Basics: • Time for lab. – Hello world. – More input/output – arrays – Functions in the main cpp file – Header files (more functions) – Classes
- Slides: 6