



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The implementation of a simple C++ program for creating and managing a list using an array with a maximum size of 100. The program includes a constructor, destructor, methods for adding and printing items, and a main function for testing the functionality.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




// List.h // Declaration of class List #ifndef LIST_H #define LIST_H const int maxSize = 100; class List { public: List(); ~List(); int numberOfItem(); // Return number of item void addItem(int item); // Add item void printItem(); // Print item in the list private : int size; // size shows the number of item in the list int array[maxSize]; // array that keep the item }; #endif // List.cpp // Define the implementation of all methods in class List #include
void List::printItem() // Print items in list { for (int i = 0; i < size; i++) cout << array[i] << " "; cout << "\n"; } // ListMain.cpp // Implementation // Create object and method implementation #include
// List.h // Declaration of class List #ifndef LIST_H #define LIST_H const int maxSize = 100; class List { public: List(); ~List(); int numberOfItem(); // Return number of item void addItem(int item); // Add item void printItem(); // Print item in the list private : int size; // size shows the number of item in the list int array[maxSize]; // array that keep the item }; #endif // List.cpp // Define the implementation of all methods in class List #include
void List::printItem() // Print items in list { for (int i = 0; i < size; i++) cout << array[i] << " "; cout << "\n"; } //ListMain.cpp //Implementation //Create object and method implementation #include