Compiling Separate C++ Files Strings & Vectors

Compiling Separate C++ Files Strings & Vectors

CS 16: Solving Problems with Computers I Lecture #14

Ziad Matni

Dept. of Computer Science, UCSB

Announcements

? Lab #8 is due on Monday, 11/21 at 8 AM ? Homework #13 is due on Thursday, 11/17

11/15/16

Matni, CS16, Fa16

2

Lecture Outline

? Compiling Separate Files in C++

CH. 8 ? Strings

? c--string vs. string Class in C++

? IntroducRon to Vectors

11/15/16

Matni, CS16, Fa16

3

C++ Programming in MulRple Files

? Novice C++ Programming:

? All in one .cpp source code file ? All the funcRon definiRons, plus the main( ) program

? Actual C++ Programming separates parts

? There are usually one or more header files with file names ending in .h that typically contain funcRon prototypes

? There are one or more files that contain funcRon definiRons, some with main( ) funcRons, and others that don't contain a main( ) funcRon

11/15/16

Matni, CS16, Fa16

4

Why?

? Reusability

? Some parts of the program are generic enough that we can use them over again ? Reuse is not necessarily just in one program!

? ModularizaRon

? Create stand--alone pieces of code ? Can contain sets of funcRons or sets of classes (or both) ? A library is a module that is in an already--compiled form (i.e. object code)

? Independent work flows

? If we have mulRple people working on a project, it is a good idea to break it into pieces so that everyone can work on their files

? Faster re--compilaRons & debug

? When you make a change, you only have to re--compile the part(s) that have changed ? Easier to debug a porRon than the enRre program!

11/15/16

Matni, CS16, Fa16

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download