Computer Science 1037A/B Lecture 19: Constructors & Destructors

16 views2 pages

Document Summary

Constructor: member function that is often used to initialize data members of a class. Is called automatically when an object of the class is created. It must be named the same as the class. A class can have more than 1 constructor. Overloaded constructors in a class must have different parameter lists. Constructors can have any number of parameters, including none. A default constructor is one that takes no arguments either due to. If a class has any programmer-defined constructors, it must have a programmer defined default constructor. To create an object using the default constructor, use no argument list and no () To create an object using a constructor that has parameters, include an argument list. Is a public member function automatically called when an object is destroyed. Only 1 destructor is allowed per class it cannot be overloaded.

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

Related Questions