CMPSC 24 Lecture 3: Lecture 3
Document Summary
Letting the objects collaborate to solve a problem. Description of a group of objects with similar properties. Separation of a data type"s logical properties from its implementation. Specific representation of the structure to hold the data items, and the coding for operations. Class = structured type that encapsulates a fixed number of data components (data members) The predefined operations on an instance of a class are whole assignment and component access. Container class = data type that is capable of holding a collection of items. Can be implemented as a class with member functions to add, remove, examine items. You can check how many occurrences of certain numbers are in the bag. You can check how many numbers are in the bag. The bag class (bag. h) class bag { capacity = 100; public: // modifiers void insert(int element); bool remove(int element); // observers int total(); int howmany(int element); private: int data[capacity]; bag. cpp.