关于c++:PIC-10B-解析

81次阅读

共计 1568 个字符,预计需要花费 4 分钟才能阅读完成。

PIC 10B Homework 5 Due Wednesday, March 10
Problem 1:
Using good coding practices, design your own Linked List of int types. It will consist
of classes List, Node, and Iterator granting friendship and defining functions as needed.
Write constructors, destructors, and all necessary member functions such as insert, erase,
increment and decrement operators, operator* to dereference, as well as operator== and
operator!= to check whether two iterators are pointing to the same element. You will then
use this list to write the following member functions:
(1) List::reverse to reverse your nodes
(2) List::push front to add a value to the beginning of a list
(3) List::sort to sort the elements of a linked list (without copying them into a vector or
another data type)
(4) List::merge which accepts another List object and merges the two lists into one, alternating
elements from each list such that merging 1 7 12 and 8 3 11 2 2 1 yields the list 1
8 7 3 12 11 2 2 1.
Write a main function to test your list such that it follows the output shown in Figure 1.
Figure 1: sample output.
Due Wednesday, March 10 Homework 5 PIC 10B
Good Coding Practices:
• think about cross-platform. Don’t use Windows or Mac only commands. For example,
pause == cin.get() twice, write many \n vs. system(clear) or system(’cls).
• passing objects by reference & or const & when possible
• using field initializer list when possible in all constructors
Instructions for submission:
• Name your files exactly hw5.cpp, List.h, List.cpp, Node.h, Node.cpp, Iterator.h,
and Iterator.cpp.
• You may not use #include “stdafx.h”.
• Add code description in the comment at the beginning of the file.
A sample description may look like:
/*
PIC 10B 2A, Homework 1
Purpose: Tic-tac-toe game
Date: 10/10/2019
*/
• Submit your header files and source codes to CCLE in separate files. Only .h and .cpp
files should be uploaded.

正文完
 0