{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

scan0006 - ANSWER KEY j Assignment in Derived should call...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ANSWER KEY j) Assignment in Derived should call Base: :operator = (*this) ,- NO — pass rhs k) If Base has friend operator<< then it is also a friend of Derived NO 5. What does the declaration of this look like inside function foo? myClass* const this; 6. What is the output? Caught something! Caught an int! Did the program explode? 7. Write a recursive function to return the number of elements in a linked list. int countList(const Node* head) if(head == NULL) return 0; return 1 + countList(head—>next); } 8. Write a function called vectorToList that takes in a vector of intS and creates a linked list with the same data in the same order. It should return the newly created list. Node* vectorToList(const vector<int>& v) { if(v.size() > 0) { Node* head = new Node(v[0]); Node* temp = head; for( size_t i = 1; i < v.size(); ++i) { temp—>next = new Node(v[iJ); temp = temp->next; } return head; } return NULL; } 9. Given an STL list<char>, use iterators to display the list. The list should be created from the elements of a char array. char str = "Bjarne Stroustrup"; list<char> 1c(str, str+17); for (list<char>::iterator itr cout << *itr << endl; 1c.begin(); itr != 1c.end(); itr++) Final Exam Review — Page 2 ...
View Full Document

{[ snackBarMessage ]}