ITP 165x Lecture Notes - Lecture 23: Virtual Function, Calcareous Sponge

75 views1 pages

Document Summary

Itp 165: intro to c++ - lecture 23, pure virtual functions, abstract classes. So conceptually, we could make a shape class and say: We want to put all the common functionality into shape. A virtual function is one that child classes can override: The = 0 means that all children of shape are required to implement this function. When you create a class that has a pure virtual function, it is called an abstract class. We call these classes abstract, because they have member functions that cannot be implemented. You cannot create instances of these classes. Classes that have all their member functions defined are called concrete classes. Without virtual functions, we could not create a single collection class like a vector that contains objects of different classes that inherit from the same base class. We would have to have a collection of each derived type.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents