Question: 7. Define a class named PrimeNumber that stores a prime number. The default con- structor should set the prime number to 1. Add another constructor

 7. Define a class named PrimeNumber that stores a prime number.

7. Define a class named PrimeNumber that stores a prime number. The default con- structor should set the prime number to 1. Add another constructor that allows the caller to set the prime number. Also, add a function to get the prime num ber. Finally, overload the prefix and postfix++ and -- operators so they 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!