Question: C++ 1. Define a class named PrimeNumber that stores a prime number. The default constructor should set the prime number to 1. 2. Add another

C++

1. Define a class named PrimeNumber that stores a prime number. The default constructor should set the prime number to 1.

2. Add another constructor that allows the caller to set the prime number.

3. Add a function to get the prime number.

4. Overload the prefix and postfix ++ and -- operators so they return a PrimeNumber object that is the next largest prime number (for ++) and the next smallest prime number (for --). For example, if the object's prime number is set to 13, then invoking ++ should return a PrimeNumber object whose prime number is set to 17. Create an appropriate test program for the class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!