CMPSC 24 Chapter Notes - Chapter 3: Default Constructor, Member Variable, Local Variable

48 views6 pages
29 Jan 2017
School
Course
Professor

Document Summary

Container class = a class in which each object contains a collection of items. Typedef statements = used to provide the ability to easily change the type of item in a container class. Bag of integers = similar to imaginary bag. Container that can hold a collection of integers that we place into it. Can be used by any program that needs to store a collection of integers for later use. Default constructor bag();to initialize a bag to be empty. Name of constructor must be the same as the name of the class. Bag objects can be copied with an assignment statement. A newly declared bag can be initialized as a copy of another bag using the copy constructor bag b; b. insert(42); bag c(b); A typedef for the value_type class bag { public: typedef int value_type; Typedef statement = consists of the keyword typedef followed by a data type and then a new identifier.

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