COMP 206 Unit 6: Initialization and Cleanup

Description

University-level C++ COMP 206 Flashcards on COMP 206 Unit 6: Initialization and Cleanup, created by Adriana Vincelli-Joma on 15/09/2021.
Adriana Vincelli-Joma
Flashcards by Adriana Vincelli-Joma, updated more than 1 year ago
Adriana Vincelli-Joma
Created by Adriana Vincelli-Joma about 3 years ago
2
0

Resource summary

Question Answer
constructor special member function that initializes class instance
destructor - constructor's complement - cleans up object when no longer needed -destructs/deletes object
definition block variables defined at the beginning of a block after opening brace
2 reasons to dispense with definition block 1. reduce duration of variable's availability within scope; reduce chance it will be misused in some other part of scope 2. readability is improved because reader doesn't have to jump back and forth to beginning of scope to know type of variable
lifetime of loop variable variable lifetime extended to end of scope that enclosed for loop
aggregate bunch of things clumped together
aggregate types 1. mixed types: structs and classes 2. single type: array
Way in which aggregate type is initialized - make assignment, and initialization will be taken care of by compiler - elements in assignment must be surrounded by curly braces -all initialization must go through constructor, even if using aggregate initialization
default constructor - called with no arguments -creates "vanilla object" -used when compiler is told to create object but isn't given any details
Show full summary Hide full summary

Similar

COMP 206 Unit 11: Operator Overloading
Adriana Vincelli-Joma
COMP 206 Unit 9: Name Control
Adriana Vincelli-Joma
COMP 206 Unit 13: Inheritance and Composition
Adriana Vincelli-Joma
COMP 206 Unit 5: Hiding the Implementation
Adriana Vincelli-Joma
COMP 206 Unit 12: Dynamic Object Creation
Adriana Vincelli-Joma
COMP 206 Unit 7: Function Overloading and Default Arguments
Adriana Vincelli-Joma
COMP 206 Unit 8: Constants
Adriana Vincelli-Joma
COMP 206 Unit 3: The C in C++
Adriana Vincelli-Joma
GOVN 377 Unit 8: The Brave New World of Data Management and Manipulation
Adriana Vincelli-Joma
HIST 404: Unit 4 Science in the Renaissance
Adriana Vincelli-Joma
HIST 404: Unit 9 Discovering DNA
Adriana Vincelli-Joma