Question: Using the Singleton pattern examples found in this chapter, create a program to accomplish the following: 1. Implement either an interface for a President to

Using the Singleton pattern examples found in this chapter, create a program to accomplish the following:

1. Implement either an interface for a President to Resign() or implement the interface to Impeach() a President. Your method should delete the current Singleton President (and remove that link from the SingletonDestroyer). SingletonDestroyer has a setSingleton() method that may be useful to aid in removing the backlink.

2. Noting that the former Singleton President has been removed, create a new President using President::instance(). Verify that the new President has been installed.

3. (Optional) Create a Registry to allow Singleton to be used effectively in multiple classes (not mutually exclusively, as is the current implementation).

Step by Step Solution

3.34 Rating (154 Votes )

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 A Practical In Depth Guide C++ Questions!