CSS 343: Notes from Lecture 14 (DRAFT)

Guest Lecture

Graph problems:

P, NP, and NP-completeness:

Administrivia

Assignment 2 has been marked.

More on C++ (cont.)

Our Story So Far...

Abstract Data Types vs. Concrete Data Types

An ADT is all about the interface; a concrete type is all about the implementation.

C++ has the equivalent of Java-style interfaces in the form of abstract base classes.

Core OO Principles

While object orientation has many associations, the three core concepts are:

  1. encapsulation
  2. inheritance
  3. polymorphism

Encapsulation

Namespaces provide another form of encapsulation.

using namespace std: bad practice?

Conclusion: Your Mileage May Vary

Never put using namespace std; into a header file. This could introduce a surprising state change into your client's code.

The basic encapsulation is, of course the class.

public and private provide a mechanism for separating interface and implementation.

Nonstatic members have an implicit parameter, a pointer to the object which is accessed via this. Direct access to a data member foo_ is identical to access via the pointer, this->foo_.

Inheritance and Polymorphism