Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented...

19
Monday, Jan 6, 2003 Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory

Transcript of Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented...

Page 1: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

CO 204

Object Oriented Programming

2003

Trent University

Kate Gregory

Page 2: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Agenda

• About Me

• Administrivia

• Overview

• Intro to C++

Page 3: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Class Times

• 3:00 – 5:00 Lecture– Usually break around 4:00 for 10-15 minutes

• 5:00 – 5:50 Tutorial– Less formal, more one-on-one

– Save non-urgent questions for this hour

Page 4: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Web Site

• www.gregcons.com/204• Lecture PowerPoints

– Usually available before class

• Companion Word and Excel documents– Assignments, handouts– Please email me if you need HTML versions of these

• Announcements of test dates and other information of interest

• Reminder of my phone numbers and email

Page 5: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Administrivia

• Text: Harvey M. Deitel, Paul J. Deitel. C++ How to Program, 3rd Edition.

• Office Hours : Before and after class and by appointment downtown

• Web Support : www.gregcons.com/204• [email protected] anytime• Grading Scheme: 7 Labs – 35%, Midterm –

25%, Final – 40%

Page 6: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Date Week Topic Chapter Hand Out Due Back Test6-Jan-03 1 Administrivia / Overview / Intro to C++ 1

13-Jan-03 2 Control Structures, Functions 2,3 Lab 120-Jan-03 3 Arrays, Pointers, Strings 4,5 Lab 2 Lab 1 5%27-Jan-03 4 Classes, Data Abstraction 6 Lab 2 5%3-Feb-03 5 More on Classes 7 Lab 3

10-Feb-03 6 Operator Overloading 8 Lab 4 Lab 3 5%17-Feb-03 Reading Break24-Feb-03 7 Inheritance 9 Lab 4 5% Midterm 25%3-Mar-03 8 Virtual Functions and Polymorphism 10 Lab 5

10-Mar-03 9 Stream IO 11 Lab 6 Lab 5 5%17-Mar-03 10 Templates 12,13 Lab 7 Lab 6 5%24-Mar-03 11 Exceptions31-Mar-03 12 File IO 14 Lab 7 5%

??? Exam Final 40%

Course Schedule

Page 7: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Labs and Assignments

• 7 Labs, each worth 5%

• Typically each will be drawn from end-of-chapter exercises in text

• One lab may cover several weeks of material

• Each is due one week after it is handed out

• Late penalties HURT

Page 8: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Marking Labs

• A working program does not mean a perfect mark

• Comment your code meaningfully• Make sure your code solves the problem

you were given• Hand in whatever “extras” are requested

such as problem statement, sample output• Some marks are allotted for test techniques

Page 9: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Overview – Topics Covered

• Introduction to C++• Control Structures• Functions• Arrays• Pointers• Strings• Classes• Data Abstraction

• Operator Overloading• Inheritance• Virtual Functions• Polymorphism• Stream IO• Templates• Exceptions• File IO

Page 10: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Design vs Coding

• You will learn how to code a feature, such as inheritance

• You will not learn how to decide whether a system should use the feature

• Design is CO 362• Most paid programmers start as coders and are

allowed to design later• You will learn the benefits and advantages of

these language features.

Page 11: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

History: C

• Evolved by Ritchie from two previous programming languages, BCPL and B– Used to develop UNIX– Used to write modern operating systems– Hardware independent (portable)– By late 1970's C had evolved to "Traditional C"

• Standardization– Many slight variations of C existed, and were incompatible– Committee formed to create a "unambiguous, machine-

independent" definition– Standard created in 1989, updated in 1999

Page 12: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

History: C++

• Superset of C developed by Bjarne Stroustrup at Bell Labs

• "Spruces up" C, and provides object-oriented capabilities

• Object-oriented design very powerful– 10 to 100 fold increase in productivity

• Dominant language in industry and academia

Page 13: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Files in C++

• foo.cpp – source code• foo.h – header file

– Typically .h files are included into source files

• Source files are each compiled into obj files• Several obj files are linked into an exe

– Sometimes a lib file is linked in also

• The exe can be executed, or run• Extensions and naming conventions may vary

Page 14: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Important times

• Compile Time• Link Time• Run Time

• When is something known?• When does an error happen?• When is a decision made?

Page 15: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

C++ Gotchas

• Case Sensitive: if and IF are different• You must declare variables• You must initialize variables• Ignores line breaks: you must mark ends of lines

with ;• Compiler does not read indents• Brace brackets {} are sometimes optional: use

them anyway

Page 16: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Strongly Typed

• All variables in C++ have a type– int,char, float, etc

int i = 3.4;

float f = “Hello”;

• The compiler is your friend

Page 17: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

The main() function

• This is what the operating system runs:

// Everybody’s first program

#include <iostream.h>

int main()

{

cout << "Hello, Trent!" ;

return 0;

}

Page 18: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

Learning Already

• Function• { }

– Indenting styles

• #include• cout <<• return

• Historical allusions: Unix, foo, Hello World

Page 19: Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.

Monday, Jan 6, 2003 Kate Gregorywith material from Deitel and Deitel

For Next class

• Read Chapters 1, 2, and 3 of text

• Ensure you know how to use the C++ compiler in the lab or on your own computer (the text comes with a copy of Visual C++.)