Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Bookmark and Share
Lecture Comments (3)

1 answer

Last reply by: Alvin Sylvain
Tue Nov 4, 2014 10:14 PM

Post by Ram Manohar Oruganti on November 3, 2014

Is virtual method similar to having an interface in Java? And what if a virtual method is not pure? Should it still be overloaded? And why should the destructor be virtual?

0 answers

Post by phong tran on August 13, 2012

When will the intermediate C++ be available?

Source Files & OO Samples

  • Separate the application into “compilation units”
  • Each compilation unit is compiled into an “object” file which can be linked into an application
  • Compilation units include a header file to define the unit interface
  • Compilation units include a source file to define unit implementation
  • Best practice is to include one class, and name the files after it
  • This separation allows the implementation to be kept “secret” to avoid misuse by callers
  • The source file can be changed without recompiling entire application
  • A header might be included in multiple places, which can cause duplicate definitions.
  • We learn how to write headers that protect from problems caused by being included multiple times.
  • We show the C++ syntax for class definitions
  • We show the C++ syntax for class prototypes, saved in the header files, and class implementation, saved in the source files
  • Virtual base methods can be used to require derived classes to implement certain methods
  • Virtual base methods also allow for inherited Polymorphism, a powerful programming tool
  • Here is a link for more information about using classes and polymorphism in C++:

Source Files & OO Samples

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Overview 0:19
  • Source File Separation 2:31
  • Compilation Units 4:24
    • Example
  • Header File (Interface) 7:23
  • Include Header File 9:25
    • Example
  • Protect from Multi-Include 11:42
    • Example
  • Source File (Implementation) 14:05
    • Algorithms
  • Commands 15:49
  • Class Syntax 17:25
    • Private Member
    • Protected Member
    • Public Member
  • Class Prototype for Header 21:13
  • Class Implementation 23:21
    • Controlled Access
  • Inheritance 25:44
    • Implementation
  • Virtual Method 29:04
    • Pointer
  • Virtual Example 32:02
    • Base Class
    • Derived Classes
  • Polymorphic Example 33:14
  • Finished 35:23