The objective of this lab is to create a class from scratch. Since a class
represents a user-defined type, it should have, like built-in types, features
to allow object declaration and assignment. Since you have just written a program
that maintains an ordered linked list, U.S.Capitals, you are being asked to transfer
what you learned to a general purpose list class, mylist
, that maintains an ordered
list of integer. The operations of the mylist
class should allow the client to build
and traverse an ordered list as well as to insert and remove elements, keeping the order.
The client program, listint.cpp, available from your teacher, can be used to check
that the mylist class works.
Chapter 21, especially pp. 370-376 for operation overloading,
pp. 376-381 for canonical features of a class, pp. 384-390 for iterators
Chapter 15, pp. 260-274 for an introduction to classes, syntax, constructors
and destructors
// mylist.h class mylist { public: .. void insert(int val); private: .. }; #include "mylist.cpp"
// mylist.cpp void mylist::insert(int val) { } ..
The mylist class you design should contain an empty constructor, at least two modifier functions, insert(maintaining the order) and remove, and some way to traverse the list without violating encapsulation. In addition, any class which is implemented with pointers should include these additional member functions -- a copy constructor, a destructor, and an overloaded assignment operator.