Create a class named Collection for which each object can hold integers. The class should have following two private data members 1. An integer pointer named data that holds a reference of an array created dynamically according to the specified size. 2. A constant integer named size to hold the maximum size of the array. Provide the implementation of following constructors and a destructor 1. A constructor which accepts an integer that represents the size of an array and initializes it to the "empty collection," i.e., a collection whose array representation contains all 0. 2. An additional constructor that receives an array of integers and the size of that array and uses the array to initialize a collection object. 3. A copy constructor to initialize a collection object with already existing object. 4. A destructor to free any memory resources occupied by the collection object. Provide following member functions for the common set operations 1. getSize returns the size of collection. 2. setElement that inserts a new integer k at index i ( both passed as argument) into a collection, if possible. 3. countElement that counts and return the total occurrences of an integer key (passed as argument) in a collection, -1 otherwise. Overload following operators 1. Assignment (=) which copies the data of one object to another. The copy should only be done if both the objects have same sizes also avoid self-assignment. 2. Stream extraction to take input from user for the ‘data’ of a collection. 3. Stream insertion to display the contents of ‘data’ on the screen of a collection. 4. Addition (+) binary operator which perform the addition of two collections if possible and return the result. 5. Arithmetic assignment operator (–=) which subtract the right hand side collection from left if possible and assign the result back to left hand side collection. 6. Minus (–) unary operator which return true if all the elements of a collection are negative, false otherwise. 7. Pre increment (++) and post decrement (--) to increment a collection by 1 and to decrement it by 1 respectivel

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a class named Collection for which each object can hold integers.
The class should have following two private data members
1. An integer pointer named data that holds a reference of an array created dynamically according to the specified size.
2. A constant integer named size to hold the maximum size of the array.
Provide the implementation of following constructors and a destructor
1. A constructor which accepts an integer that represents the size of an array and initializes it to the "empty collection,"
i.e., a collection whose array representation contains all 0.
2. An additional constructor that receives an array of integers and the size of that array and uses the array to initialize a
collection object.
3. A copy constructor to initialize a collection object with already existing object.
4. A destructor to free any memory resources occupied by the collection object.
Provide following member functions for the common set operations
1. getSize returns the size of collection.
2. setElement that inserts a new integer k at index i ( both passed as argument) into a collection, if possible.
3. countElement that counts and return the total occurrences of an integer key (passed as argument) in a collection, -1
otherwise.
Overload following operators
1. Assignment (=) which copies the data of one object to another. The copy should only be done if both the objects have
same sizes also avoid self-assignment.
2. Stream extraction to take input from user for the ‘data’ of a collection.
3. Stream insertion to display the contents of ‘data’ on the screen of a collection.
4. Addition (+) binary operator which perform the addition of two collections if possible and return the result.
5. Arithmetic assignment operator (–=) which subtract the right hand side collection from left if possible and assign the
result back to left hand side collection.
6. Minus (–) unary operator which return true if all the elements of a collection are negative, false otherwise.
7. Pre increment (++) and post decrement (--) to increment a collection by 1 and to decrement it by 1 respectivel

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education