/* Filename: list.cpp Author: Br. David Carlson Date: June 29, 1999 Last Revised: September 19, 2022 This program adds some characters to the end of a list and then prints the list in two different ways. Tested with: Microsoft Visual C++ 2019 */ #include #include #include #include using namespace std; // Function prototypes: template void PrintA(list& L); void PrintB(list& L); int main(void) { list L; L.push_back('A'); L.push_back('B'); L.push_back('C'); PrintA(L); PrintB(L); return 0; } /* Given: L A list containing items of type T. Task: To print out the contents of list L. Return: Nothing. */ template void PrintA(list& L) { cout << "Contents of list:" << endl; for (auto p = begin(L); p != end(L); p++) cout << *p << " "; cout << endl << endl; } /* Given: Item A character item. Task: To print out Item. Return: Nothing. */ void PrintItem(char Item) { cout << Item << " "; } /* Given: L A list containing characters. Task: To print out the contents of list L. Return: Nothing. */ void PrintB(list& L) { cout << "Contents of list:" << endl; for_each(L.begin(), L.end(), PrintItem); cout << endl << endl; }