Question
please use c++ 1. Please create a class TheaterSeat, which has two member variables and one static variable: private: int * VIPSeat; int *regularSeat; static
please use c++
1. Please create a class TheaterSeat, which has two member variables and one static variable: private: int * VIPSeat; int *regularSeat; static int swapCount; //This static variable will tally the total number of swaps made by all TheaterSeat instances. It's probably a nonsensical variable, I just wanted to dump it in for you to practice 'static.'
2. Please create a function called swap(), apart from other necessary member functions (getters, setters, constructor, etc). Inside the swap() function, you will need to swap the values (memory addresses) of the pointers variables VIPSeat and regularSeat. (Note: not to swap the de-referenced values, but the reference values - memory addresses). You may increment the static variable swapTotal value inside the swap() function. public: void swap();
3. In your main() function, please create at least two instances of TheaterSeat class. For two instances, you need to create four local variables, say int seat1, int seat2, int seat3, and int seat4. Assign some (unique) numbers to each of seats. Associate two of the seat numbers to instance 1's VIP seat and regular seat; the other two for instance 2. Then swap the VIP seat and the regular Seat using swap() member function for each of the instances. Lastly, display the VIP seat number and the regular seat number for instance 1 and instance 2, as well as the total swap count (display the value of the static variable swapCount).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started