COM SCI 32 Lecture Notes - Lecture 6: Linked List

58 views6 pages

Document Summary

Question: which of the following use the copy constructor and which use the assignment operator? int main() Answer: copy constructor; de(cid:210)ning e, which didn"t exist before, and initializing it to d"s values. Every time you call a member function of an object, e. g. : a. addbill(5); C++ invisibly rewrites your function call and passes in the variable"s address! addbill(&a, 5); void wallet::init() num1s = num5s = 0; void init(wallet *this) this->num1s = this->num5s = 0; int main() This is how it actually works under the hood C++ hides the "this pointer" from you to simplify things. Any time you don"t know how many items you"ll need to store ahead of time, you use linked lists. Allows you to store an arbitrary number of items. Makes it fast to insert a new item in the middle. Makes it fast to delete an item from the middle struct chest string treasure; Chest *first; //gives us the location to our first clue.

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

Related Questions