1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Which method is the default constructor of the class?
Resources are allocated without prior deletion, and no OUTSIDE information is used to set the members
Which method is the copy constructor of the class?
Resources are allocated without prior deletion, and another instance is used to set the members
Which method is a non copy, non default constructor of a class?
Resources are allocated without prior deletion, and an input different from the associated class is used to set the members
Which method is the assignment operator of the class?
Allocations and deallocations are balances, and another instance is used to set the members
Which method is the destructor of the class
Resources are freed without a matching allocation
From a programmer's perspective, the way methods work with their parameters is different compared to the "normal" functions declared outside of classes. Explain this difference.
Methods take a pointer to an instance of their class as an
implicit parameter. Every member of the instance pointed by
the implicit parameter can be accessed as though it was a
local variable in the method body
What is the purpose of an access specifier, and where are they used? Provide one example of an access specifier.
used to control whether or not a
method / member in a class definition is externally
accessible. An example of an access specifier is "public",
which marks methods / members as externally accessible.
What is the purpose of a default constructor?
A default constructor is used to initialize the state of a class instance when no external information is supplied for that initialization.
When are default constructors called?
When a class instance is declared without any parameters and without assignment, the instance is implicitly initialized through its class's default constructor.
What is the purpose of an overloaded assignment operator?
An overloaded assignment operator is used to copy the state
of one instance of a class into another pre-existing instance
of the class (providing additional logic compared to default
assignment behavior). This is particularly important for
classes which have invariants based around exclusive
ownership of a resource.
When are overloaded assignment operators called?
Overloaded assignment operators are called when an instance
of the corresponding class is assigned into another instance of
the same class outside of the assignee's declaration
what are the differences between .cpp and .h files?
.cpp is where you define the methods and functions and you initialize methods, classes, constructors, etc in .h
What defines the ordering of elements in a linked list?
The ordering of the elements in a linked list is defined by
the pointer values stored at each node. The node identified
by this pointer (or a null address) indicates how the ordering
progresses directly after the associated element
Compare and contrast linked list
ordering relative to how arrays order their values.
Arrays store all elements contiguously, and the position of
an element in an array's ordering is determined by the
element's position in memory relative to adjacent elements.
In essence, linked lists represent their order explicitly with
pointer values, whereas arrays represent their order
implicitly through their element's addresses
Can a linked list simultaneously store elements in different types of storage
(static/stack/dynamic)? Why or why not?
Yes, as long as mixing storage types does not violate any of
the invariants imposed upon the linked list implementation.
The structure/ordering of a linked list is defined through the
pointer values at each of the nodes. Pointers can be held in
any type of storage and can point into any type of storage,
so nothing inherently disallows joining nodes from different
types of storage