Computer Science 1037A/B Lecture Notes - Lecture 41: Virtual Function, Abstract Type, In C

25 views1 pages

Document Summary

Abstract class: a class that contains no objects that are not members of subclasses (derived classes) Example - in real life, animal is an abstract class: there are no animals that are not dogs, or cats, or lions . Abstract classes can be used to specify an interface that must be implemented by all subclasses. The member functions specified in an abstract class do not have to be implemented. In c++, an abstract class is a class with at least one abstract member function. In c++, a member function of a class is declared to be an abstract function by making it virtual and replacing its body with = 0; A virtual function with its body omitted and replaced with =0 is called a pure virtual function, or an abstract function. An abstract class can only be inherited from; that is, you can derive classes from it.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents