struct insert_at_back_of_sll { // Function takes a constant Book as a parameter, inserts that book at the // back of a singly linked list, and returns nothing. void operator()(const Book& book) { // TO-DO (3) |||| // Write the lines of code to insert "book" at the back of "my_sll", Since // the SLL has no size() function and no tail pointer, you must walk the // list looking for the last node. // // HINT: Do not attempt to insert after "my_sll.end()". /////// ND-TO-D (3) ||||/ /// } std::forward_list& my_sll; };

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
icon
Concept explainers
Question
struct insert_at_back_of_sll {
// Function takes a constant Book as a parameter, inserts that book at the
// back of a singly linked list, and returns nothing.
void operator()(const Book& book) {
/// TO-DO (3)
///
// Write the lines of code to insert "book" at the back of "my_sll". Since
// the SLL has no size() function and no tail pointer, you must walk the
// list looking for the last node.
//
// HINT: Do not attempt to insert after "my_sll.end()".
//
///// END-T0-DO (3) ||||//
}
std::forward_list<Book>& my_sll;
};
Transcribed Image Text:struct insert_at_back_of_sll { // Function takes a constant Book as a parameter, inserts that book at the // back of a singly linked list, and returns nothing. void operator()(const Book& book) { /// TO-DO (3) /// // Write the lines of code to insert "book" at the back of "my_sll". Since // the SLL has no size() function and no tail pointer, you must walk the // list looking for the last node. // // HINT: Do not attempt to insert after "my_sll.end()". // ///// END-T0-DO (3) ||||// } std::forward_list<Book>& my_sll; };
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning